public void AddChildBirth(ChildBirth childBirth) { using (var context = new RabbitsDBEntities()) { context.ChildBirth.Add(childBirth); context.SaveChanges(); } }
public ChildBirthParrents Convert(ChildBirth childBirth) { return new ChildBirthParrents { Female = new FemalesRepository().GetFemale(childBirth.FemaleId), Male1 = new MalesRepository().GetMale(childBirth.MaleId1), Male2 = childBirth.MaleId2 != null ? new MalesRepository().GetMale((int) childBirth.MaleId2) : null, Result = new ResultsRepository().GetResult(childBirth.ResultId), ChildBirth = childBirth }; }
public ActionResult UpdateChildBirth(ChildBirth childBirth, FormCollection formCollection) { try { if (ModelState.IsValid) { AddDataFromDdls(childBirth, formCollection); new ChildBirthManager().UpdateChildBirth(childBirth); } return RedirectToAction(ShowChildBirthAction); } catch (InvalidOperationException exception) { return RedirectToAction(ErrorAction, new {exception}); } }
public void UpdateChildBirth(ChildBirth childBirth) { using (var context = new RabbitsDBEntities()) { var result = context.ChildBirth.FirstOrDefault(x => x.Id == childBirth.Id); if (result == null) throw new InvalidOperationException(NotFound); result.FemaleId = childBirth.FemaleId; result.Birthday = childBirth.Birthday; result.ExpectBirthday = childBirth.ExpectBirthday; result.Notes = childBirth.Notes; result.MaleId1 = childBirth.MaleId1; result.MaleId2 = childBirth.MaleId2; result.StartDate1 = childBirth.StartDate1; result.StartDate2 = childBirth.StartDate2; result.ResultId = childBirth.ResultId; context.SaveChanges(); } }
public void UpdateChildBirth(ChildBirth childBirthParrents) { new ChildBirthRepository().UpdateChildBirth(childBirthParrents); }
public void AddChildBirth(ChildBirth childBirthParrents) { new ChildBirthRepository().AddChildBirth(childBirthParrents); }
private static void AddDataFromDdls(ChildBirth childBirth, FormCollection formCollection) { if (formCollection["ddlMale1"] == null || formCollection["ddlMale2"] == null || formCollection["ddlFemale"] == null || formCollection["ddlResult"] == null) throw new InvalidOperationException(ErrorLists); var male1Id = formCollection["ddlMale1"]; var male2Id = formCollection["ddlMale2"]; var femaleId = formCollection["ddlFemale"]; var resultId = formCollection["ddlResult"]; childBirth.MaleId1 = int.Parse(male1Id); childBirth.MaleId2 = int.Parse(male2Id); childBirth.FemaleId = int.Parse(femaleId); childBirth.ResultId = int.Parse(resultId); }