public ActionResult Post(AnimalNotDonkey animal) { try { _db.NotDonkeys.Add(animal); _db.SaveChanges(); return(StatusCode((int)HttpStatusCode.Created)); } catch (Exception) { return(StatusCode((int)HttpStatusCode.ExpectationFailed)); } }
public async Task <IActionResult> Create([Bind("Id,OwnerPhoneNumber,Name,Password,AnimalType,Sex,Weight,AdditionalDescription,IsDonkey,AnimalsYouLike")] AnimalNotDonkey animalNotDonkey) { try { if (ModelState.IsValid && !animalNotDonkey.IsDonkey) { animalNotDonkey.AnimalType = AnimalService.Instance.SetAnimalType(animalNotDonkey.AnimalType); _db.Add(animalNotDonkey); await _db.SaveChangesAsync(); StaticDetails.DonkeysAvailableToLike = _db.NotDonkeys.ToList(); return(View("Login")); } return(View(animalNotDonkey)); } catch (Exception ex) { SetErrorDetails(ex, "Error occured during creating new animal"); return(RedirectToAction("ThrowErrorMessage")); } }
public void Post(AnimalNotDonkey animal) { _db.NotDonkeys.Add(animal); _db.SaveChanges(); }