public ActionResult Add(Models.Personnel.AddViewModel model) { if (!ModelState.IsValid) { return(View(model)); } Data.Entity.Personnel personnel = new Data.Entity.Personnel(); personnel.TC = model.TC; personnel.Name = model.Name; personnel.LastName = model.LastName; personnel.Phone = model.Phone; personnel.Address = model.Address; personnel.UserName = model.UserName; personnel.Password = model.Password; var result = _personnelService.Add(personnel); if (result > 0) { return(RedirectToAction(nameof(PersonnelController.List))); } else { ViewBag.ErrorMessage = "Not Saved"; return(View(model)); } }
public ActionResult Edit(Models.Personnel.AddViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var personnel = _personnelService.GetById(model.Id); if (personnel == null) { return(View("_ErrorNotExist")); } personnel.TC = model.TC; personnel.Name = model.Name; personnel.LastName = model.LastName; personnel.Phone = model.Phone; personnel.Address = model.Address; personnel.UserName = model.UserName; personnel.Password = model.Password; var result = _personnelService.Update(personnel); if (result <= 0) { ViewBag.ErrorMessage = "Not Edited"; return(View(model)); } return(RedirectToAction(nameof(PersonnelController.List))); }
public ActionResult Add(Models.Personnel.AddViewModel modell) { if (!ModelState.IsValid) { ViewBag.ErrorMessage = "Error."; return(View(modell)); } Business.Models.Personnel.AddRequestModel personnel = new Business.Models.Personnel.AddRequestModel(); personnel.TC = modell.TC; personnel.Name = modell.Name; personnel.LastName = modell.LastName; personnel.Phone = modell.Phone; personnel.Address = modell.Address; personnel.UserName = modell.UserName; personnel.Password = modell.Password; var apiResponseModel = _personnelService.Add(personnel).Result; if (apiResponseModel.Status == ResultStatusCodeStatic.Success) { return(RedirectToAction(nameof(PersonnelController.List))); } else { ViewBag.ErrorMessage = apiResponseModel.Message != null ? apiResponseModel.Message : "Kaydedilemedi.";//todo: kulturel olacak NotSaved return(View(modell)); } }
public ActionResult Edit(Models.Personnel.AddViewModel model) { if (!ModelState.IsValid) { //select list model.HospitalSelectList = GetHospitalSelectList(); return(View(model)); } //select list model.HospitalSelectList = GetHospitalSelectList(); try { var personnel = _personnelService.GetById(model.Id); if (personnel == null) { return(View("_ErrorNotExist")); } personnel.TC = model.TC; personnel.Name = model.Name; personnel.LastName = model.LastName; personnel.Phone = model.Phone; personnel.Address = model.Address; personnel.UserName = model.UserName; personnel.Password = model.Password; personnel.HospitalId = model.HospitalId; if (model.SubmitType == "Edit") { var existPersonnel = _personnelService.GetByUserName(model.UserName); if (existPersonnel != null) { if (existPersonnel.Id != model.Id) { ViewBag.ErrorMessage = "Exist Personnel."; return(View(model)); } } _personnelService.Update(personnel); } return(RedirectToAction(nameof(PersonnelController.List))); } catch { ViewBag.ErrorMessage = "Not Operation."; return(View(model)); } }
public ActionResult Edit(Models.Personnel.AddViewModel modell) { if (!ModelState.IsValid) { return(View(modell)); } var apiResponseModel = _personnelService.GetById(modell.Id).Result; if (apiResponseModel.Status != ResultStatusCodeStatic.Success) { ViewBag.ErrorMessage = apiResponseModel.Message; return(View(modell)); } var personnel = apiResponseModel.Data; if (personnel == null) { return(View("_ErrorNotExist")); } AddRequestModel editModel = new AddRequestModel(); editModel.Id = personnel.Id; editModel.TC = modell.TC; editModel.Name = modell.Name; editModel.LastName = modell.LastName; editModel.Phone = modell.Phone; editModel.Address = modell.Address; editModel.UserName = modell.UserName; editModel.Password = modell.Password; var apiEditResponseModel = _personnelService.Edit(modell.Id, editModel).Result; if (apiEditResponseModel.Status != ResultStatusCodeStatic.Success) { ViewBag.ErrorMessage = apiEditResponseModel.Message != null ? apiEditResponseModel.Message : "Not Edited"; return(View(modell)); } return(RedirectToAction(nameof(PersonnelController.List))); }
public ActionResult Add(Models.Personnel.AddViewModel model) { if (!ModelState.IsValid) { //select list model.HospitalSelectList = GetHospitalSelectList(); return(View(model)); } //select list model.HospitalSelectList = GetHospitalSelectList(); HealthyDuty.Data.Entity.Personnel personnel = new HealthyDuty.Data.Entity.Personnel(); personnel.TC = model.TC; personnel.Name = model.Name; personnel.LastName = model.LastName; personnel.Phone = model.Phone; personnel.Address = model.Address; personnel.UserName = model.UserName; personnel.Password = model.Password; personnel.HospitalId = model.HospitalId; try { var existPersonnel = _personnelService.GetByUserName(model.UserName); if (existPersonnel != null) { ViewBag.ErrorMessage = "Exist Personnel."; return(View(model)); } _personnelService.Add(personnel); return(RedirectToAction(nameof(PersonnelController.List))); } catch { ViewBag.ErrorMessage = "Not Saved."; return(View(model)); } }