public void SaveContactSet(EmployeeContactViewModel model) { AspNetUser AddUser = _db.AspNetUsers.Where(x => x.Id == model.Id).FirstOrDefault(); EmployeeAddressInfo AddressInfo = _db.EmployeeAddressInfoes.Where(x => x.UserId == model.Id).FirstOrDefault(); EmployeeBankInfo BankInfo = _db.EmployeeBankInfoes.Where(x => x.UserId == model.Id).FirstOrDefault(); //step 4 AddUser.WorkPhone = model.WorkPhone; AddUser.WorkMobile = model.WorkMobile; //Address Details AddressInfo.CountryId = model.Country; AddressInfo.StateId = model.State; AddressInfo.TownId = model.Town; AddressInfo.AirportId = model.Airport; AddressInfo.HousNumber = model.HouseNumber; AddressInfo.PostCode = model.Postcode; AddressInfo.PersonalPhone = model.PersonalPhone; AddressInfo.PersonalMobile = model.PersonalMobile; AddressInfo.PersonalEmail = model.PersonalEmail; //Bank details BankInfo.BankAddress = model.Address; BankInfo.BankName = model.BankName; BankInfo.BankCode = model.BankCode; BankInfo.AccountNumber = model.AccountNumber; BankInfo.OtherAccountInformation = model.OtherAccountInformation; BankInfo.AccountName = model.AccountName; BankInfo.BankAddress = model.BankAddress; BankInfo.IBAN_No = model.IBAN_Number; BankInfo.SWIFT_Code = model.SWIF_Code; _db.SaveChanges(); }
public EmployeeContactViewModel employeeDetailsById(int Id) { EmployeeContactViewModel Companysetting = new EmployeeContactViewModel(); Companysetting.Id = Id; var model = _db.AspNetUsers.Where(x => x.Id == Id).FirstOrDefault(); EmployeeAddressInfo AddressInfo = _db.EmployeeAddressInfoes.Where(x => x.UserId == model.Id).FirstOrDefault(); EmployeeBankInfo BankInfo = _db.EmployeeBankInfoes.Where(x => x.UserId == model.Id).FirstOrDefault(); Companysetting.Id = model.Id; if (AddressInfo != null) { if (AddressInfo.TownId != 0) { var city = _db.Cities.Where(x => x.Id == AddressInfo.TownId).FirstOrDefault(); var state = _db.States.Where(x => x.Id == city.StateId).FirstOrDefault(); var country = _db.Countries.Where(x => x.Id == state.CountryId).FirstOrDefault(); Companysetting.Country = country.Id; Companysetting.CountryValue = country.Name; Companysetting.State = state.Id; Companysetting.StateValue = state.Name; Companysetting.Town = (int)AddressInfo.TownId; Companysetting.TownValue = city.Name; } if (AddressInfo.AirportId != null && AddressInfo.AirportId > 0) { var airport = _db.Airports.Where(x => x.Id == AddressInfo.AirportId).FirstOrDefault(); Companysetting.Airport = (int)AddressInfo.AirportId; Companysetting.AirportValue = airport.Name; } } if (BankInfo != null) { Companysetting.Address = BankInfo.BankAddress; Companysetting.WorkPhone = model.WorkPhone; Companysetting.WorkMobile = model.WorkMobile; Companysetting.HouseNumber = AddressInfo.HousNumber; Companysetting.Postcode = AddressInfo.PostCode; Companysetting.PersonalPhone = AddressInfo.PersonalPhone; Companysetting.PersonalMobile = AddressInfo.PersonalMobile; Companysetting.PersonalEmail = AddressInfo.PersonalEmail; Companysetting.BankName = BankInfo.BankName; Companysetting.BankCode = BankInfo.BankCode; Companysetting.IBAN_Number = BankInfo.IBAN_No; Companysetting.SWIF_Code = BankInfo.SWIFT_Code; Companysetting.AccountNumber = BankInfo.AccountNumber; Companysetting.OtherAccountInformation = BankInfo.OtherAccountInformation; Companysetting.AccountName = BankInfo.AccountName; Companysetting.BankAddress = BankInfo.BankAddress; Companysetting.EmployeeId = Convert.ToInt32(AddressInfo.UserId); } foreach (var item in _db.Countries.ToList()) { if (AddressInfo != null) { if (AddressInfo.CountryId == item.Id) { Companysetting.CountryList.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString(), Selected = true }); } else { Companysetting.CountryList.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString() }); } } } foreach (var item in _db.States.ToList()) { if (AddressInfo != null) { if (AddressInfo.StateId == item.Id) { Companysetting.StateList.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString(), Selected = true }); } else { Companysetting.StateList.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString() }); } } } foreach (var item in _db.Cities.ToList()) { if (AddressInfo != null) { if (AddressInfo.TownId == item.Id) { Companysetting.TownList.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString(), Selected = true }); } else { Companysetting.TownList.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString() }); } } } foreach (var item in _db.Airports.ToList()) { if (AddressInfo != null) { if (AddressInfo.AirportId == item.Id) { Companysetting.AirportList.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString(), Selected = true }); } else { Companysetting.AirportList.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString() }); } } } return(Companysetting); }
public int SaveResourcetSet(MainResoureViewModel model) { //AspNetUser AddUser = _db.AspNetUsers.Where(x => x.Id == model.Id).FirstOrDefault(); AspNetUser AddUser = new AspNetUser(); //step 1 AddUser.NameTitle = model.Title; AddUser.FirstName = model.FirstName; AddUser.LastName = model.LastName; AddUser.OtherNames = model.OtherNames; AddUser.KnownAs = model.KnownAs; AddUser.SSOID = model.SSO.ToUpper(); AddUser.UserName = model.UserNameEmail; AddUser.IMAddress = model.IMAddress; AddUser.Gender = model.Gender; AddUser.Archived = false; AddUser.PasswordHash = model.PasswordHash; AddUser.CreatedDate = DateTime.Now; AddUser.CreatedBy = SessionProxy.UserId; if (model.DateOfBirth != null) { var DateOfBirthToString = DateTime.ParseExact(model.DateOfBirth, inputFormat, CultureInfo.InvariantCulture); AddUser.DateOfBirth = Convert.ToDateTime(DateOfBirthToString.ToString(outputFormat)); } AddUser.Nationality = model.Nationality; AddUser.NINumberSSN = model.NIN_SSN; AddUser.image = model.Picture; AddUser.IsReadAddReport = false; AddUser.IsReadArchived = false; AddUser.IsReadHRRespo = false; //Step 2 if (model.StartDate != null) { var StartDateToString = DateTime.ParseExact(model.StartDate, inputFormat, CultureInfo.InvariantCulture); AddUser.StartDate = Convert.ToDateTime(StartDateToString.ToString(outputFormat)); } AddUser.ResourceType = model.ResourceType; //AddUser.Reportsto = model.Reportsto; AddUser.AdditionalReportsto = model.AdditionalReportsto; AddUser.HRResponsible = model.HRResponsible; AddUser.JobTitle = model.JobTitle; AddUser.JobContryID = model.JobCountrID; AddUser.Location = model.Location; //AddUser.BusinessID = model.BusinessID; //AddUser.DivisionID = model.DivisionID; //AddUser.PoolID = model.PoolID; //AddUser.FunctionID = model.FunctionID; //step 3 if (model.ProbationEndDate != null) { var ProbationEndDateToString = DateTime.ParseExact(model.ProbationEndDate, inputFormat, CultureInfo.InvariantCulture); AddUser.ProbationEndDate = Convert.ToDateTime(ProbationEndDateToString.ToString(outputFormat)); } if (model.NextProbationReviewDate != null) { var NextProbationReviewDateToString = DateTime.ParseExact(model.NextProbationReviewDate, inputFormat, CultureInfo.InvariantCulture); AddUser.ProbationEndDate = Convert.ToDateTime(NextProbationReviewDateToString.ToString(outputFormat)); } if (model.FixedTermEndDate != null) { var FixedTermEndDateToString = DateTime.ParseExact(model.FixedTermEndDate, inputFormat, CultureInfo.InvariantCulture); AddUser.FixedTermEndDate = Convert.ToDateTime(FixedTermEndDateToString.ToString(outputFormat)); } AddUser.NoticePeriod = model.NoticePeriodID; AddUser.MethodofRecruitmentSetup = model.MethodofRecruitmentSetup; AddUser.RecruitmentCost = model.RecruitmentCost.ToString(); // AddUser.CurrenciesId = model.curruncyID; if (model.HolidaysThisYear != null) { AddUser.Thisyear = (int)model.HolidaysThisYear; } if (model.HolidaysNextYear != null) { AddUser.Nextyear = (int)model.HolidaysNextYear; } if (model.IncludePublicHoliday != null) { if (model.IncludePublicHoliday == "on") { AddUser.IncludePublicHoliday = true; } else { AddUser.IncludePublicHoliday = false; } } if (model.HolidayEntit != 0 && model.HolidayEntit != null) { AddUser.HolidayEntitlement = model.HolidayEntit; } //step 4 //AddUser.Country = model.CountryId; //AddUser.State = model.StateId; //AddUser.Town = model.CityyId; //AddUser.Airport = model.AirportId; //AddUser.Postcode = model.PostalCode; //AddUser.BankAddress = model.Address; AddUser.WorkPhone = model.WorkPhone; AddUser.WorkMobile = model.WorkMobile; //AddUser.PersonalPhone = model.PersonalPhone; //AddUser.PersonalMobile = model.PersonalMobile; //AddUser.PersonalEmail = model.PersonalEmail; //AddUser.BankName = model.BankName; //AddUser.BankCode = model.BankCode; //AddUser.AccountNumber = model.AccountNumber; //AddUser.OtherAccountInformation = model.OtherAccountInformation; //AddUser.AccountName = model.AccountName; //AddUser.BankAddress = model.BankAddress; AddUser.CreatedBy = model.CurrentUserId; //Step 5 JavaScriptSerializer js = new JavaScriptSerializer(); List <AddnewtaskRecordmodel> listValueArray = js.Deserialize <List <AddnewtaskRecordmodel> >(model.JsonNewtaskList); foreach (var item in listValueArray) { Task_List ModelNew = new Task_List(); ModelNew.InRelationTo = model.Id; ModelNew.Title = item.Title; ModelNew.Description = item.Description; ModelNew.AssignTo = item.Assign; ModelNew.Archived = false; ModelNew.AlterBeforeDays = item.AlertBeforeDays; if (item.DueDate != "") { var DueDateToString = DateTime.ParseExact(item.DueDate, inputFormat, CultureInfo.InvariantCulture); ModelNew.DueDate = Convert.ToDateTime(DueDateToString.ToString(outputFormat)); } ModelNew.Status = item.Status; ModelNew.LastModified = DateTime.Now; ModelNew.Created = DateTime.Now; _db.Task_List.Add(ModelNew); } _db.AspNetUsers.Add(AddUser); _db.SaveChanges(); if (AddUser.Id > 0) { //Employee Relation EmployeeRelation _employeeRelation = new EmployeeRelation(); _employeeRelation.UserID = AddUser.Id; if (model.Reportsto != null) { _employeeRelation.Reportsto = model.Reportsto.Value; } _employeeRelation.BusinessID = model.BusinessID; _employeeRelation.DivisionID = model.DivisionID; _employeeRelation.PoolID = model.PoolID; _employeeRelation.FunctionID = model.FunctionID; _employeeRelation.CreateBy = model.CurrentUserId; _employeeRelation.CreatedDate = DateTime.Now; _employeeRelation.IsActive = true; _db.EmployeeRelations.Add(_employeeRelation); //Employee Address Info EmployeeAddressInfo _EmployeeAddressInfo = new EmployeeAddressInfo(); _EmployeeAddressInfo.UserId = AddUser.Id; _EmployeeAddressInfo.CountryId = model.CountryId; _EmployeeAddressInfo.StateId = model.StateId; _EmployeeAddressInfo.TownId = model.CityyId; _EmployeeAddressInfo.AirportId = model.AirportId; _EmployeeAddressInfo.PostCode = model.PostalCode; _EmployeeAddressInfo.ContactAddress = model.Address; _EmployeeAddressInfo.PersonalPhone = model.PersonalPhone; _EmployeeAddressInfo.PersonalMobile = model.PersonalMobile; _EmployeeAddressInfo.PersonalEmail = model.PersonalEmail; _db.EmployeeAddressInfoes.Add(_EmployeeAddressInfo); EmployeeBankInfo _EmployeeBankInfo = new EmployeeBankInfo(); _EmployeeBankInfo.UserId = AddUser.Id; _EmployeeBankInfo.BankName = model.BankName; _EmployeeBankInfo.BankCode = model.BankCode; _EmployeeBankInfo.AccountName = model.AccountName; _EmployeeBankInfo.AccountNumber = model.AccountNumber; _EmployeeBankInfo.OtherAccountInformation = model.OtherAccountInformation; _EmployeeBankInfo.BankAddress = model.BankAddress; _EmployeeBankInfo.IBAN_No = model.IBAN_Number; _EmployeeBankInfo.SWIFT_Code = model.SWIFT_Code; _db.EmployeeBankInfoes.Add(_EmployeeBankInfo); } if (model.ApplicantID != 0 && model.ApplicantID != null) { var AccepteID = _AdminTMSMethod.GetAcceptedStepId((int)model.ApplicantID); var data = _db.TMS_Applicant.Where(x => x.Id == model.ApplicantID).FirstOrDefault(); data.Archived = true; data.StatusID = AccepteID; data.LastModified = DateTime.Now; } _db.SaveChanges(); return(AddUser.Id); }