public DoctorViewModel ModifyDoctor(DoctorViewModel model) { try { DBOperations op = model.IsActive ? DBOperations.Update : DBOperations.Delete; model.Doctor.SiteCode = AppConstants.SITE_CODE; if (model.IsActive) { model.IsValid = model.Validate(); if (model.IsValid) { //model.Address = base.TranslateNames(model.Address); //var mgr = _bdmSvc.GetEntityById(AppConstants.SITE_CODE, decimal.Zero); // model.Doctor.ParentEntityID); //if (mgr != null && mgr.Addresses.Count > 0) //{ // var src = mgr.Addresses[0]; // AddressDE dest = model.Address; // Translate(src, ref dest); //} //if (model.Doctor.Addresses.Count > 0) // model.Doctor.Addresses[0] = model.Address.Translate(model.Doctor.Addresses[0]); //if (model.Doctor.Contacts.Count > 0) // model.Doctor.Contacts[0] = model.Contact.Translate(model.Doctor.Contacts[0]); _bdmSvc.ModifyEntity(model.Doctor); } } else { model.Doctor.IsActive = false; _bdmSvc.ModifyEntity(model.Doctor); } model = RefreshDoctor(); model.Message = op == DBOperations.Update ? string.Format(AppConstants.CRUD_UPDATE, "Doctor") : string.Format(AppConstants.CRUD_DELETE, "Doctor"); } catch (Exception ex) { model.TranslateException(ex); if (ex.Message.Contains("Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540 for information on understanding and handling optimistic concurrency exceptions.")) model.Message = "Unable to modify Region Code"; } return model; }
public DoctorViewModel AddDoctor(DoctorViewModel model) { try { model.IsValid = model.Validate(); if (model.IsValid) { model.Doctor.SiteCode = AppConstants.SITE_CODE; //var mgr = _bdmSvc.GetEntityById(AppConstants.SITE_CODE, decimal.Zero); // model.Doctor.ParentEntityID); //if (mgr != null && mgr.Addresses.Count > 0) //{ // var src = mgr.Addresses[0]; // AddressDE dest = model.Address; // Translate(src, ref dest); //} //model.Doctor.Addresses.Add(model.Address); //model.Doctor.Contacts.Add(model.Contact); //_bdmSvc.AddEntity(model.Doctor); //model = RefreshDoctor(); //model.Message = string.Format(AppConstants.CRUD_CREATE, "Doctor"); } } catch (Exception ex) { model.TranslateException(ex); } return model; }