private void MapUpdatedFields(AdopterContract newAdopter, AdopterContract oldAdopter) { oldAdopter.ID = newAdopter.ID; oldAdopter.Name = newAdopter.Name; oldAdopter.Phone = newAdopter.Phone; oldAdopter.State = newAdopter.State; oldAdopter.AddressLine = newAdopter.AddressLine; oldAdopter.Email = newAdopter.Email; }
public void Add(AdopterContract adopter) { try { using (var context = new DatabaseContext()) { context.Adopters.Add(adopter); context.SaveChanges(); } } catch (Exception e) { throw e; } }
public OperationResult Edit(AdopterContract adopter) { try { if (adopter == null) { return(new OperationResult(false, "Null contract.")); } _adopterRepository.Edit(adopter); return(new OperationResult(true, "Adopter edited.")); } catch (Exception e) { return(new OperationResult(false, e.Message)); } }
public void Edit(AdopterContract newAdopter) { try { using (var context = new DatabaseContext()) { var oldAdopter = context.Adopters.First(x => x.ID == newAdopter.ID); MapUpdatedFields(newAdopter, oldAdopter); context.SaveChanges(); } } catch (Exception e) { throw e; } }
public OperationResult Add(AdopterContract adopter) { try { if (adopter == null) { return(new OperationResult(false, "Null contract.")); } adopter.ID = Guid.NewGuid(); adopter.CreatedOn = DateTime.Now; _adopterRepository.Add(adopter); return(new OperationResult(true, "Adopter added.")); } catch (Exception e) { return(new OperationResult(false, e.Message)); } }
public JsonResult Edit(AdopterContract adopter) { var result = _adopterService.Edit(adopter); return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult Add(AdopterContract adopter) { var result = _adopterService.Add(adopter); return(Json(result)); }
public AdoptionContract(AdopterContract Adopter, AnimalContract Animal) { this.Adopter = Adopter; this.Animal = Animal; }