public async Task <bool> AddPetAsync(PetCreate pet) { var ownerId = User?.Id; var content = CreateContent(pet); var response = await HttpClient.PostAsync($"{Url}/Animal/{ownerId}", content); return(response.StatusCode == HttpStatusCode.OK); }
public ActionResult Create(PetCreate model) { if (ModelState.IsValid) { var service = CreatePetService(); service.CreatePet(model); return(RedirectToAction("Index")); } return(View(model)); }
public bool CreatePet(PetCreate model) { var entity = new Pet { Name = model.Name, TypeOfPet = model.TypeOfPet, ClientId = model.ClientId }; _context.Pets.Add(entity); return(_context.SaveChanges() == 1); }
public bool CreatePet(PetCreate model) { var entity = new Pet { Name = model.Name, PetOwnerId = _userId, PetType = model.PetType, }; _dbContext.Pets.Add(entity); return(_dbContext.SaveChanges() == 1); }
public IHttpActionResult Post(PetCreate pet) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreatePetService(); if (!service.CreatePet(pet)) { return(InternalServerError()); } return(Ok()); }
public bool CreatePet(PetCreate model) { var entity = new Pet() { OwnerId = _userId, HouseId = _houseId, Name = model.Name, PetAge = model.PetAge, Personality = model.Personality }; using (var ctx = new ApplicationDbContext()) { ctx.Pets.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(PetCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreatePetService(); if (service.CreatePet(model)) { TempData["SaveResult"] = "Your pet was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Pet could not be created."); return(View(model)); }
public bool AdminCreatePet(PetCreate model) { var entity = new Pet() { Name = model.Name, SizeOfDog = model.SizeOfDog, IsHairLong = model.IsHairLong, SpecialRequest = model.SpecialRequest, Birthday = model.Birthday, DateAdded = DateTimeOffset.Now, PersonID = model.PersonID, }; _context.Pets.Add(entity); return(_context.SaveChanges() == 1); }
public bool CreatePet(PetCreate model) { var entity = new Pet() { OwnerId = _userId, Name = model.Name, Species = model.Species, Breed = model.Breed, Weight = model.Weight, DateOfBirth = model.DateOfBirth, MealsPerDay = model.MealsPerDay }; using (var ctx = new ApplicationDbContext()) { ctx.Pets.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreatePet(PetCreate model) { var customerService = new CustomerService(_userID); var customerDetail = customerService.GetCustomerByCurrentUserId(); var entity = new Pet() { Name = model.Name, SizeOfDog = model.SizeOfDog, IsHairLong = model.IsHairLong, SpecialRequest = model.SpecialRequest, Birthday = model.Birthday, DateAdded = DateTimeOffset.Now, PersonID = customerDetail.PersonID, }; _context.Pets.Add(entity); return(_context.SaveChanges() == 1); }