public ActionResult Create([Bind(Include = "Id,PatientCode,Name,Surname,NameOfFather,NameOfMother,InsuranceCode,Gender,DateOfBirth,Address,HomePhone,WorkingPhone,MobilePhone,RadiographyCode,Reasoning,RadiographyActions,SuggestedDate,Priority,Status,Doctor")] Radiography radiography) { if (ModelState.IsValid) { var user = db.Users.Find(radiography.Doctor.Id); radiography.Doctor = user; radiography.DateOfSubmission = DateTime.Now; radiography.CreatedBy = db.Users.Find(User.Identity.GetUserId()); radiography.Created = DateTime.Now; db.Radiographies.Add(radiography); try { db.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } return(RedirectToAction("Index")); } return(View(radiography)); }
public ActionResult DeleteConfirmed(int id) { Radiography radiography = db.Radiographies.Find(id); db.Radiographies.Remove(radiography); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,RadiographyCode,IssueDate,Details,RadiographyActions,Status")] Radiography radiography) { if (ModelState.IsValid) { db.Entry(radiography).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(radiography)); }
public static RadiographyView EntityToView(this Radiography entity) { if (entity != null) { return(new RadiographyView { Id = entity.Id, Info = entity.Info, InjuriesDiseasesId = entity.InjuriesDiseasesId }); } return(null); }
public void InsertRadiography(int id, Radiography radiography) { var entity = context.InjuriesDiseases.FirstOrDefault(t => t.Id == id); if (entity == null) { throw new NullReferenceException(); } radiography.Id = 0; entity.Radiographies.Add(radiography); context.SaveChanges(); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Radiography radiography = db.Radiographies.Find(id); if (radiography == null) { return(HttpNotFound()); } return(View(radiography)); }
public ActionResult Edit([Bind(Include = "Id,PatientCode,Name,Surname,NameOfFather,NameOfMother,InsuranceCode,Gender,DateOfBirth,Address,HomePhone,WorkingPhone,MobilePhone,RadiographyCode,DateOfSubmission,Reasoning,RadiographyActions,SuggestedDate,SuggestedDateTime,Priority,Status")] Radiography radiography) { if (ModelState.IsValid) { db.Entry(radiography).State = EntityState.Modified; radiography.Created = DateTime.Now; radiography.Modified = DateTime.Now; radiography.ModifiedBy = db.Users.Find(User.Identity.GetUserId()); radiography.SuggestedDate = radiography.SuggestedDate + radiography.SuggestedDateTime; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(radiography)); }
public ActionResult Create(RadiographyVM vm) { if (ModelState.IsValid) { var random = new Random(); var Patient = new Patient { PatientCode = random.Next().ToString(), Name = vm.PatientName, Surname = vm.PatientSurname, NameOfFather = vm.PatientsFatherName, NameOfMother = vm.PatientsMotherName, AMKA = vm.AMKA, Birthdate = vm.Birthdate, Address = vm.Address, HomePhone = vm.Phone1, WorkPhone = vm.Phone2, MobilePhone = vm.Phone3 }; db.Patients.Add(Patient); db.SaveChanges(); var Radiograpgy = new Radiography() { RadiographyCode = random.Next().ToString(), IssueDate = DateTime.Now, Details = vm.Details, RadiographyActions = vm.RadiographyActions, Doctor = db.Users.Find(User.Identity.GetUserId()), Priority = vm.Priority, Status = Enums.Enums.Status.Created, Patient = db.Patients.Find(Patient.Id) }; db.Radiographies.Add(Radiograpgy); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(View(vm)); }