public IHttpActionResult Post(AdoptCreate adoption) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateAdoptionServices(); if (!service.CreateAdoption(adoption)) { return(InternalServerError()); } return(Ok()); }
public bool CreateAdoption(AdoptCreate model) { if (model.UserType == UserType.customer) { var entity = new Adoption() { UserId = _userId, PostId = model.PostId, }; using (var ctx = new ApplicationDbContext()) { ctx.Adoptions.Add(entity); return ctx.SaveChanges() == 1; } } else { Console.WriteLine("Would you like to make a customer account?"); } return false; }