public ActionResult Details(int id) { var hi = this.db.HealthInsurances.Single(h => h.Id == id); var viewModel = new HealthInsuranceViewModel { Id = hi.Id, Name = hi.Name, NewAppointmentValue = hi.NewAppointmentValue, ReturnAppointmentValue = hi.ReturnAppointmentValue, ReturnDaysInterval = hi.ReturnTimeInterval, IsActive = hi.IsActive, IsParticular = hi.IsParticular, }; return this.View(viewModel); }
public ActionResult Edit(int? id, bool isParticular = false) { var viewModel = new HealthInsuranceViewModel { ReturnDaysInterval = 30, IsActive = true, IsParticular = isParticular, }; this.ViewBag.IsEditingOrCreating = id != null ? 'E' : 'C'; if (id != null) { var healthInsurance = this.db.HealthInsurances.First(m => m.Id == id); viewModel = new HealthInsuranceViewModel { Id = healthInsurance.Id, Name = healthInsurance.Name, ReturnAppointmentValue = healthInsurance.ReturnAppointmentValue, NewAppointmentValue = healthInsurance.NewAppointmentValue, ReturnDaysInterval = healthInsurance.ReturnTimeInterval, IsActive = healthInsurance.IsActive, IsParticular = healthInsurance.IsParticular, }; } return this.View("Edit", viewModel); }
public ActionResult Create(HealthInsuranceViewModel viewModel) { return this.Edit(viewModel); }
public ActionResult Edit(HealthInsuranceViewModel formModel) { if (this.ModelState.IsValid) { HealthInsurance healthInsurance; if (formModel.Id != null) healthInsurance = this.db.HealthInsurances.First(m => m.Id == formModel.Id); else { healthInsurance = new HealthInsurance(); this.db.HealthInsurances.AddObject(healthInsurance); healthInsurance.DoctorId = this.Doctor.Id; healthInsurance.PracticeId = this.Doctor.PracticeId; } healthInsurance.Name = formModel.Name; healthInsurance.NewAppointmentValue = formModel.NewAppointmentValue; healthInsurance.ReturnAppointmentValue = formModel.ReturnAppointmentValue; healthInsurance.ReturnTimeInterval = formModel.ReturnDaysInterval; healthInsurance.IsActive = formModel.IsActive; healthInsurance.IsParticular = formModel.IsParticular; this.db.SaveChanges(); return this.Redirect(this.Url.Action("Details", new { id = healthInsurance.Id })); } return this.View("Edit", formModel); }