Skip to main content

Dog food

Blue Buffalo is a premium dog food brand created by a family for their own beloved furry companion. Blue Buffalo offers nutritious recipes that include natural ingredients, high quality meat, fish or poultry, and fruits and vegetables. They produce healthy recipes for all stages of life, all sizes, and all activity levels. Introducing Blue Buffalo Bill and Jackie Bishop began to take an interest in pet health issues when their Airedale,Introducing Blue Buffalo Bill and Jackie Bishop began to take an interest in pet health issues when their    or all stages of life, all sizes, and all activity levels.      Airedale,

 



dotnet new mvc --auth none

HomeController.

using System;

using System.Collections.Generic;

using System.Diagnostics;

using System.Linq;

using System.Threading.Tasks;

using Microsoft.AspNetCore.Mvc;

using Microsoft.Extensions.Logging;

using ma.Models;

namespace ma.Controllers

{ public class HomeController : Controller

 {public String Index()

 {return "Hello Deepak";

}}}

[dotnet run]

StockQuote.cs

using System;

namespace ma.Models

{

 public class StockQuote

 {

 public string Symbol {get;set;}

 public int Price{get;set;}

 }}

Ma/views/home/

Index.cshtml

@{

 ViewData["Title"] = "Home Page";

}

<div

 Symbol: @Model.Symbol <br/>

 Price: $@Model.Price <br/>

</div>

AGAIN controller:

using System;

using System.Collections.Generic;

using System.Diagnostics;

using System.Linq;

using System.Threading.Tasks;

using Microsoft.AspNetCore.Mvc;

using Microsoft.Extensions.Logging;

using ma.Models;

namespace ma.Controllers

{

 public class HomeController : Controller

 {

 public async Task <IActionResult> Index()

 {

 var model=new StockQuote {Symbol="Hello", Price=3200};

 return View(model);

 }

 }

}

[dotnet run]

Building ASP.Net core REST API

[dotnet new webapi -o Glossary] (cmd 1)

[cd Glossary] [dotnet run] (cmd 1)

[curl –insecure https://localhost:7018/weatherforecast] (cmd 2)

ma2\Glossary\GlossaryItem.cs

//GlossaryItem.cs

namespace Glossary

{

 public class GlossaryItem

 {

 public string Term { get; set;}

 public string Definition { get; set;}

 }

}

Glossary\Controllers\ GlossaryController.cs

using System;

using System.Collections.Generic;

using Microsoft.AspNetCore.Mvc;

using System.IO;

namespace Glossary.Controllers

{

[ApiController]

[Route("api/[controller]")]

public class GlossaryController:ControllerBase

{

 private static List<GlossaryItem>Glossary=new List<GlossaryItem>

 {

 new GlossaryItem

 {

 Term="HTML", Definition="HyperText Markup language"

 },

 new GlossaryItem

 {

 Term="MVC", Definition="Model View Control"

 },

 new GlossaryItem

 {

 Term="OpenID", Definition="An Open Standard For Autehntication"

 }

 };

[HttpGet]

public ActionResult<List<GlossaryItem>>Get()

{

 return Ok(Glossary);

}

[HttpGet]

[Route("{term}")]

public ActionResult<GlossaryItem>Get(string term)

{

 var glossaryItem=Glossary.Find(item=>item.Term.Equals(term,StringComparison.InvariantCultureIgnoreCase));

 if(glossaryItem==null)

 {return NotFound();

 }else

 {

 return Ok(glossaryItem);

 }

}

[HttpPost]

public ActionResult Post(GlossaryItem glossaryItem)

{

var existingGlossaryItem=Glossary.Find(item=>item.Term.Equals(glossaryItem.Term,StringComparison.InvariantCultureIgnoreCase));

if (existingGlossaryItem!= null)

{

return Conflict("Cannnot create the term because it already exists");

}

else

{

 Glossary.Add(glossaryItem);

 var resourseUrl=Path.Combine(Request.Path.ToString(),Uri.EscapeUriString(glossaryItem.Term));

 return Created(resourseUrl,glossaryItem);

}

}

[HttpPut]

 public ActionResult Put(GlossaryItem glossaryItem)

 {

 var existingGlossaryItem=Glossary.Find(item=>item.Term.Equals(glossaryItem.Term,StringComparison.InvariantCultureIgnoreCase));

 if (existingGlossaryItem==null)

 {

 return BadRequest("Cannnot update a non existing Term");

 }

 else

 {

 existingGlossaryItem.Definition=glossaryItem.Definition;

 return Ok();

 }

 }

[HttpDelete]

[Route("{term}")]

public ActionResult Delete(string term)

{

 var glossaryItem=Glossary.Find(item=>item.Term.Equals(term,StringComparison.InvariantCultureIgnoreCase));

 if(glossaryItem==null)

 {

 return NotFound();

 }

 else

 {

 Glossary.Remove(glossaryItem);

 return NoContent();

 }

}

}

}

curl --insecure https://localhost:7018/api/glossary

Getting a single item

curl --insecure https://localhost:7018/api/glossary/MVC

Creating an Item:

curl --insecure -X PUT -d "{\"term\":\"MVC\",\"definition\":\"Modified record of Model View Controller.\"}" -H "Content-Type:application/json"

https://localhost:7018/api/glossary

Update Item:

curl --insecure -X PUT -d "{\"term\":\"MVC\",\"definition\":\"Modified record of Model View Controller.\"}" -H "Content-Type:application/json"

https://localhost:7018/api/glossary

Delete Item:

Command [ curl --insecure --request DELETE –url

Comments

Popular posts from this blog

Dog muzzle: when to use it and how to choose it?

  The muzzle is an accessory that is sometimes useful, and sometimes even indispensable and obligatory.  Unfortunately, the image your dog will convey by wearing this accessory will often be negative, since the muzzle is often associated with the idea of ​​a mean dog, although this is definitely not always the case.  It is sometimes only criminally obligatory in certain situations and for certain types of dogs, whereas the dog concerned may very well be the nicest in the world. From a practical point of view and comfort for your four-legged companion, it will also be necessary to choose the right muzzle adapted to your dog, because indeed, all types of muzzles are not suitable for all dogs, or even for all situations. When to have your dog wear a muzzle? The muzzle should not be an accessory that the dog wears all day.  Let's not forget that this obstructs a very important part of his body, and that as it would be for a human, it will inevitably end up greatly annoyi...

5 Diffrence between cat and dogs

  5 differences between dog and cat: Being like a dog and a cat often means that we are too different to get along.  Yet, many dogs and cats can be seen sharing the same household.  And luckily, because there is nothing cuter than seeing a house dog and cat get along.  Do you know what are the differences between the dog and the cat?  Here they are : 1- Domestication Dogs and cats weren't domesticated at the same time.  And although domestication is still debated in the dates, it is widely believed that the dog was domesticated before the cat. Indeed, the dog would have been domesticated at least 15,000 years ago.  Whereas, the cat would have been domesticated 10,000 years ago according to the latest discoveries. This difference explains in part why we have received ideas such as “a cat does not stand up” because it is more difficult to find something to motivate a cat in order to cooperate. 2- Living hours The dog will live at your own pace.  At ...

Gps dog fence: How to choose the Best Gps dog fence ?

  Dogs feel best when they live outdoors instead of staying at home all day, even if you live in the country or on a farm, you shouldn't let your dog walk where he wants to. The best way to keep your dog within certain boundaries is to use smart special equipment -  a cordless electric dog fence is the way to go  .  Forget about heavy chains and ropes - now your puppy will no longer run away. What is a wireless dog fence and who needs it? a Dog Fence is not a fence in the traditional sense of the word.  It is an intelligent electronic system that consists of a transmitter, a receiver and (sometimes) wires.  The receiver is attached to a dog collar.  As soon as the puppy gets too close to the border defined by its owner, it receives an alarm signal in the form of a slight electric shock, vibrations or sounds.  If he tries to cross the border, the intensity of the stimulation increases, causing him to stop and turn around. In the modern context, an ...