public async Task <JsonResult> SaveAboutData(PayrollCompanyConfigurationDTO data) { var id = data.ID.HasValue ? data.ID.Value : Guid.NewGuid(); if (!data.ID.HasValue) { throw new CotorraException(101, "101", "No es posible crear otra configuración, sólo se puede tener 1 por empresa", null); } else { var payrollConfiguration = (await _clientConfiguration.FindAsync(p => p.ID == id, SessionModel.CompanyID)).FirstOrDefault(); payrollConfiguration.ComercialName = data.ComercialName; payrollConfiguration.CompanyBusinessSector = data.CompanyBusinessSector; payrollConfiguration.CompanyCreationDate = string.IsNullOrEmpty(data.CompanyCreationDate) ? (DateTime?)null : CotorraTools.ValidateDate(data.CompanyCreationDate); payrollConfiguration.CompanyWebSite = data.CompanyWebSite; payrollConfiguration.Facebook = data.Facebook; payrollConfiguration.Instagram = data.Instagram; payrollConfiguration.CompanyScope = data.CompanyScope; payrollConfiguration.CompanyInformation = data.CompanyInformation; var resultJSON = SaveConfiguration(payrollConfiguration); } return(Json(data)); }
public async Task <JsonResult> Save(PayrollCompanyConfigurationDTO data) { var lstPayrollCompanyConfig = new List <PayrollCompanyConfiguration>(); var id = data.ID.HasValue ? data.ID.Value : Guid.NewGuid(); //Assign id and Map var result = _mapper.Map <PayrollCompanyConfigurationDTO, PayrollCompanyConfiguration>(data); result.ID = id; lstPayrollCompanyConfig.Add(result); var lstAddress = new List <Address>() { new Address() { ID = data.AddressID.HasValue ? data.AddressID.Value : Guid.NewGuid(), Active = true, company = SessionModel.CompanyID, CompanyID = SessionModel.CompanyID, CreationDate = DateTime.Now, DeleteDate = null, Description = "", ExteriorNumber = data.ExteriorNumber, FederalEntity = data.FederalEntity, IdentityID = SessionModel.IdentityID, InstanceID = SessionModel.InstanceID, InteriorNumber = data.InteriorNumber, Municipality = data.Municipality, Name = "", Reference = data.Reference, StatusID = 1, Street = data.Street, Suburb = data.Suburb, Timestamp = DateTime.Now, user = SessionModel.IdentityID, ZipCode = data.ZipCode } }; //Address if (!data.AddressID.HasValue) { await _clientAddress.CreateAsync(lstAddress, SessionModel.CompanyID); } else { await _clientAddress.UpdateAsync(lstAddress, SessionModel.CompanyID); } //Configuration if (!data.ID.HasValue) { throw new CotorraException(101, "101", "No es posible crear otra configuración, sólo se puede tener 1 por empresa", null); } else { var payrollConfiguration = (await _clientConfiguration.FindAsync(p => p.ID == id, SessionModel.CompanyID)).FirstOrDefault(); //Data that cannot be replaced lstPayrollCompanyConfig.FirstOrDefault().company = payrollConfiguration.company; lstPayrollCompanyConfig.FirstOrDefault().InstanceID = payrollConfiguration.InstanceID; lstPayrollCompanyConfig.FirstOrDefault().user = SessionModel.IdentityID; lstPayrollCompanyConfig.FirstOrDefault().Timestamp = DateTime.Now; lstPayrollCompanyConfig.FirstOrDefault().Name = ""; lstPayrollCompanyConfig.FirstOrDefault().Description = ""; lstPayrollCompanyConfig.FirstOrDefault().RFC = payrollConfiguration.RFC; lstPayrollCompanyConfig.FirstOrDefault().AddressID = lstAddress.FirstOrDefault().ID; lstPayrollCompanyConfig.FirstOrDefault().CurrencyID = payrollConfiguration.CurrencyID; lstPayrollCompanyConfig.FirstOrDefault().CurrentExerciseYear = payrollConfiguration.CurrentExerciseYear; lstPayrollCompanyConfig.FirstOrDefault().CurrentPeriod = payrollConfiguration.CurrentPeriod; await _clientConfiguration.UpdateAsync(lstPayrollCompanyConfig, SessionModel.CompanyID); } await SavePeriodTypes(SessionModel.CompanyID, SessionModel.InstanceID, data.HolidayPremiumPaymentType); return(Json(data)); }
public async Task <JsonResult> SaveVacationConfigData(PayrollCompanyConfigurationDTO data) { await SavePeriodTypes(SessionModel.CompanyID, SessionModel.InstanceID, data.HolidayPremiumPaymentType); return(Json(data)); }
public async Task <JsonResult> SaveGeneralData(PayrollCompanyConfigurationDTO data) { var id = data.ID.HasValue ? data.ID.Value : Guid.NewGuid(); var lstAddress = new List <Address>() { new Address() { ID = data.AddressID.HasValue ? data.AddressID.Value : Guid.NewGuid(), Active = true, company = SessionModel.CompanyID, CompanyID = SessionModel.CompanyID, CreationDate = DateTime.Now, DeleteDate = null, Description = "", ExteriorNumber = data.ExteriorNumber, FederalEntity = data.FederalEntity, IdentityID = SessionModel.IdentityID, InstanceID = SessionModel.InstanceID, InteriorNumber = data.InteriorNumber, Municipality = data.Municipality, Name = "", Reference = data.Reference, StatusID = 1, Street = data.Street, Suburb = data.Suburb, Timestamp = DateTime.Now, user = SessionModel.IdentityID, ZipCode = data.ZipCode } }; //Address if (!data.AddressID.HasValue) { await _clientAddress.CreateAsync(lstAddress, SessionModel.CompanyID); } else { await _clientAddress.UpdateAsync(lstAddress, SessionModel.CompanyID); } //Configuration if (!data.ID.HasValue) { throw new CotorraException(101, "101", "No es posible crear otra configuración, sólo se puede tener 1 por empresa", null); } else { var payrollConfiguration = (await _clientConfiguration.FindAsync(p => p.ID == id, SessionModel.CompanyID)).FirstOrDefault(); payrollConfiguration.CURP = data.CURP; payrollConfiguration.SalaryZone = data.SalaryZone; payrollConfiguration.FiscalRegime = data.FiscalRegime; payrollConfiguration.AddressID = lstAddress.FirstOrDefault().ID; var resultJSON = SaveConfiguration(payrollConfiguration); } return(Json(data)); }