public ActionResult SubmitUpdateEmployee(int id, string empCode, string empFirstName, string empLastMiddle, string empIdentifierNumber, string empAddress, string empDistrict, string empCity, string empCountry, string empPhone, string empEmail, string empWebsite, string empSummary) { logger.EnterMethod(); try { var emp = new VM_StaffInformation() { Id = id, StaffCode = empCode, FirstName = empFirstName, LastMiddle = empLastMiddle, IdentifierNumber = empIdentifierNumber, Summary = empSummary, IsInUse = true, Image = "[nullimage]", Salary = (decimal)0 }; var insertSuccess = this._iStaffServices.UpdateEmployee(ConvertVM.VMStaffInformation_To_Staff(emp)); if (insertSuccess) // Insert new employee success { var contactForId = this._iContactInformationServices.GetContactForId("Staff"); var contactTypeId = this._iContactInformationServices.GetContactTypeId("Address"); var empId = this._iStaffServices.GetLast(); var contactInformation = new VM_ContactInformation() { Address = new VM_Address() { AddressNumberNoAndStreet = empAddress, District = new VM_District() { DistrictName = empDistrict, Province = new VM_Province() { ProvinceName = empCity, Country = new VM_Country() { CountryName = empCountry } } } }, ContactForId = contactForId, ContactTypeId = contactTypeId, EAddress = new VM_EAddress() { Email = empEmail, NumberPhone = empPhone, Website = empWebsite, StaffId = empId.Id }, IsInUse = true, PersonId = empId.Id }; var updateContactInformation = this._iContactInformationServices.CheckContactInformationExistingAndUpdateForPerson(ConvertVM.VMContactInformation_To_ContactInformation(contactInformation)); if (updateContactInformation) { return(Json(JsonConvert.SerializeObject(JObject.Parse(@"{insertEmp: true, updateContactInformation: true, personid: '" + empId.Id + "'}")))); } else { return(Json(JsonConvert.SerializeObject(JObject.Parse(@"{insertEmp: true, updateContactInformation: false, personid: '" + empId.Id + "'}")))); } } else { return(Json(JsonConvert.SerializeObject(JObject.Parse(@"{insertEmp: false}")))); } } catch (Exception ex) { logger.Error("Error: [" + ex.Message + "]"); return(Json(@"{insertEmp: false}")); } finally { logger.LeaveMethod(); } }
internal static ContactInformation VMContactInformation_To_ContactInformation(VM_ContactInformation vM_ContactInformation) { logger.EnterMethod(); try { return(new ContactInformation() { Id = vM_ContactInformation.Id, Address = VMAddress_To_Address(vM_ContactInformation.Address), AddressId = vM_ContactInformation.AddressId, EAdressId = vM_ContactInformation.EAdressId, ContactForId = vM_ContactInformation.ContactForId, ContactTypeId = vM_ContactInformation.ContactTypeId, IsInUse = vM_ContactInformation.IsInUse, PersonId = vM_ContactInformation.PersonId, EAddress = VMEAddress_To_EAddress(vM_ContactInformation.EAddress) }); } catch (Exception e) { logger.Error("Error: [" + e.Message + "]"); return(new ContactInformation()); } finally { logger.LeaveMethod(); } }
internal static void VM_StaffAddContactInformation(ref VM_Staff VM_Staff, VM_ContactInformation VM_ContactInformation) { VM_Staff.ContactInformation = VM_ContactInformation; }