public List <Pet> GetAllByType(Pettype type) { var list = _petShopRepo.GetPets(); var query = list.Where(pet => pet.Type.Equals(type)); return(query.ToList()); }
public Pettype NewType(string name) { var newtype = new Pettype() { TypeName = name }; return(newtype); }
public ActionResult <Pettype> Put(int id, [FromBody] Pettype type) { try { return(StatusCode(202, _petTypeService.UpdateType(type))); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public ActionResult <Pettype> Post([FromBody] Pettype type) { try { return(StatusCode(201, _petTypeService.CreateType(type))); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public Pettype UpdateType(Pettype updatetype) { var typefromDB = this.FindPetTypeById(updatetype.Id); if (typefromDB != null) { typefromDB.TypeName = updatetype.TypeName; return(typefromDB); } return(null); }
public ActionResult Update(Guid id) { Pettype pet = _pettypeService.GetByID(id); PettypeDTO model = new PettypeDTO(); model.ID = pet.ID; model.PettypeName = pet.PettypeName; model.PettypeDescription = pet.PettypeDescription; model.SeoTitle = pet.SeoTitle; model.SeoDescription = pet.SeoDescription; return(View(model)); }
public Pettype CreateType(Pettype type) { if (_petTypeRepo.FindPetTypeById(type.Id) == null) { throw new InvalidDataException("Type not found"); } if (type.TypeName == null) { throw new InvalidDataException("Type needs a name"); } return(_petTypeRepo.AddType(type)); }
public Pettype UpdateType(Pettype updatetype) { var type = FindTypeById(updatetype.Id); if (type.Id != updatetype.Id || updatetype.Id < 1) { throw new InvalidDataException("Parameter Id and Type Id must be the same"); } if (updatetype.TypeName == null) { throw new InvalidDataException("Type must have a name"); } type.TypeName = updatetype.TypeName; return(type); }
public ActionResult Update(PettypeDTO data) { Pettype pet = _pettypeService.GetByID(data.ID); pet.ID = data.ID; pet.PettypeName = data.PettypeName; pet.PettypeDescription = data.PettypeDescription; pet.SeoTitle = data.SeoTitle; pet.SeoDescription = data.SeoDescription; _pettypeService.Update(pet); TempData["Successful"] = "Transaction is successful."; return(Redirect("/Admin/Pettype/List")); }
public Pet NewPet(string name, Pettype type, DateTime birthDate, DateTime soldDate, string color, List <Owner> Owner, double price) { var newpet = new Pet() { Name = name, Type = type, BirthDate = birthDate, SoldDate = soldDate, Color = color, Owner = Owner, Price = price }; return(newpet); }
public Pettype AddType(Pettype type) { type.Id = _id++; types.Add(type); return(type); }
public ActionResult Add(Pettype data) { _pettypeService.Add(data); return(Redirect("/Admin/Pettype/List")); }