public async Task <IActionResult> AddExcelMapping(ExcelMappingAC excelMappingAC) { string userId = HttpContext.User.Claims.FirstOrDefault(c => c.Type == "user_id").Value; string fullname = HttpContext.User.Claims.FirstOrDefault(c => c.Type == "fullname").Value; return(Ok(await _iExcelMappingRepository.AddExcelMapping(excelMappingAC, Convert.ToInt64(userId), fullname))); }
public async Task <bool> checkExcelMappingExistsForServices(ExcelMappingAC excelMappingAC) { bool IsExists = false; try { if (excelMappingAC != null) { if (excelMappingAC.ProviderId > 0 && excelMappingAC.ServiceTypeId > 0) { Mappingexcel mapingData = await _dbTeleBilling_V01Context.Mappingexcel.Where(x => x.ServiceTypeId == excelMappingAC.ServiceTypeId && x.ProviderId == excelMappingAC.ProviderId && x.IsActive && !x.IsDelete).FirstOrDefaultAsync(); if (mapingData != null) { if (mapingData.Id > 0) { IsExists = true; } } if (excelMappingAC.ServiceTypeIdInline != null) { if (excelMappingAC.ServiceTypeIdInline.Count() > 0) { //List<Mappingexcel> mapingDatalist = new List<Mappingexcel>(); var mapingDatalist = await _dbTeleBilling_V01Context.Mappingexcel .Where(x => !x.IsDelete && x.ProviderId == excelMappingAC.ProviderId && excelMappingAC.ServiceTypeIdInline.Select(s => s.Id).Contains(x.ServiceTypeId) ).ToListAsync(); if (mapingDatalist != null) { if (mapingDatalist.Count > 0) { IsExists = true; } } } } } } return(IsExists); } catch (Exception e) { return(IsExists); } }
public async Task <IActionResult> CheckExcelMappingExists(ExcelMappingAC excelMappingAC) { bool isExists = false; ResponseAC responeAC = new ResponseAC(); if (excelMappingAC != null || (excelMappingAC.ProviderId > 0 && excelMappingAC.ServiceTypeId > 0)) { isExists = await _iExcelMappingRepository.checkExcelMappingExistsForServices(excelMappingAC); if (isExists) { responeAC.Message = "excel mapping is already exists"; responeAC.StatusCode = Convert.ToInt16(TeleBillingUtility.Helpers.Enums.EnumList.ResponseType.Error); return(Ok(responeAC)); } } responeAC.Message = "excel mapping is valid"; responeAC.StatusCode = Convert.ToInt16(TeleBillingUtility.Helpers.Enums.EnumList.ResponseType.Success); return(Ok(responeAC)); }
public async Task <ResponseAC> EditExcelMapping(ExcelMappingAC excelMappingAC, long userId, string loginUserName) { ResponseAC responeAC = new ResponseAC(); try { if (excelMappingAC.dbfieldList.Count() == 0) { responeAC.Message = "Mapping Column Is Missing"; responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Error); return(responeAC); } Mappingexcel mappingexcel = new Mappingexcel(); mappingexcel = await _dbTeleBilling_V01Context.Mappingexcel.FirstOrDefaultAsync(x => x.ProviderId == excelMappingAC.ProviderId && x.ServiceTypeId == excelMappingAC.ServiceTypeId && !x.IsDelete && x.Id == excelMappingAC.Id); if (mappingexcel != null && mappingexcel.Id > 0) { #region Check For Common Mapped service not already exists bool IsValidServices = true; if (excelMappingAC.ServiceTypeIdInline != null) { if (excelMappingAC.ServiceTypeIdInline.Count() > 0) { List <DrpResponseAC> ValidServiceTypeIdInline = _iStaticRepository.ProviderCommonServiceTypeList(mappingexcel.ProviderId, mappingexcel.Id); if (ValidServiceTypeIdInline != null) { if (ValidServiceTypeIdInline.Count() > 0) { var invalidService = excelMappingAC.ServiceTypeIdInline.Where(x => !ValidServiceTypeIdInline.Select(s => s.Id).Contains(x.Id)).ToList(); if (invalidService != null) { if (invalidService.Count() > 0) { IsValidServices = false; } } } else { IsValidServices = false; } } else { IsValidServices = false; } if (!IsValidServices) { responeAC.Message = "selected services for provider mapping is invalid."; responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Error); return(responeAC); } } } #endregion #region Transaction Log Entry if (mappingexcel.TransactionId == null) { mappingexcel.TransactionId = _iLogManagement.GenerateTeleBillingTransctionID(); } var jsonSerailzeObj = JsonConvert.SerializeObject(mappingexcel); await _iLogManagement.SaveRequestTraseLog(Convert.ToInt64(mappingexcel.TransactionId), userId, Convert.ToInt64(EnumList.TransactionTraseLog.UpdateRecord), jsonSerailzeObj); #endregion mappingexcel.HaveHeader = excelMappingAC.HaveHeader; mappingexcel.HaveTitle = excelMappingAC.HaveTitle; mappingexcel.TitleName = excelMappingAC.TitleName; mappingexcel.WorkSheetNo = Convert.ToInt64(excelMappingAC.WorkSheetNo); mappingexcel.ExcelColumnNameForTitle = string.IsNullOrEmpty(excelMappingAC.ExcelColumnNameForTitle) ? "" : excelMappingAC.ExcelColumnNameForTitle; mappingexcel.ExcelReadingColumn = string.IsNullOrEmpty(excelMappingAC.ExcelReadingColumn) ? "0" : excelMappingAC.ExcelReadingColumn; mappingexcel.UpdatedBy = userId; mappingexcel.UpdatedDate = DateTime.Now; _dbTeleBilling_V01Context.Update(mappingexcel); await _dbTeleBilling_V01Context.SaveChangesAsync(); responeAC.Message = _iStringConstant.ExcelMappingUpdatedSuccessfully; responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Success); await _iLogManagement.SaveAuditActionLog((int)EnumList.AuditLogActionType.EditExcelMapping, loginUserName, userId, "Excel mapping", (int)EnumList.ActionTemplateTypes.Edit, mappingexcel.Id); if (mappingexcel.Id > 0) { #region --> Remove Old Common Mapping List <Mappingexcel> mappingCommonList = new List <Mappingexcel>(); mappingCommonList = await _dbTeleBilling_V01Context.Mappingexcel.Where(x => x.MappedMappingId == mappingexcel.Id).ToListAsync(); if (mappingCommonList != null) { if (mappingCommonList.Count() > 0) { _dbTeleBilling_V01Context.RemoveRange(mappingCommonList); await _dbTeleBilling_V01Context.SaveChangesAsync(); } } #endregion if (excelMappingAC.ServiceTypeIdInline != null) { if (excelMappingAC.ServiceTypeIdInline.Count() > 0) { #region ---> Add Common Servive if exists foreach (var serviceType in excelMappingAC.ServiceTypeIdInline) { Mappingexcel mappingexcelCommon = new Mappingexcel(); mappingexcelCommon.Id = 0; mappingexcelCommon.IsActive = true; mappingexcelCommon.ProviderId = excelMappingAC.ProviderId; mappingexcelCommon.CurrencyId = mappingexcel.CurrencyId; mappingexcelCommon.ServiceTypeId = serviceType.Id; mappingexcelCommon.HaveHeader = excelMappingAC.HaveHeader; mappingexcelCommon.HaveTitle = excelMappingAC.HaveTitle; mappingexcelCommon.TitleName = excelMappingAC.TitleName; mappingexcelCommon.WorkSheetNo = Convert.ToInt64(excelMappingAC.WorkSheetNo); mappingexcelCommon.ExcelColumnNameForTitle = string.IsNullOrEmpty(excelMappingAC.ExcelColumnNameForTitle) ? "" : excelMappingAC.ExcelColumnNameForTitle; mappingexcelCommon.ExcelReadingColumn = string.IsNullOrEmpty(excelMappingAC.ExcelReadingColumn) ? "0" : excelMappingAC.ExcelReadingColumn; mappingexcelCommon.CreatedBy = userId; mappingexcelCommon.CreatedDate = DateTime.Now; mappingexcelCommon.TransactionId = mappingexcel.TransactionId; mappingexcelCommon.IsCommonMapped = true; mappingexcelCommon.MappedMappingId = mappingexcel.Id; mappingexcelCommon.MappedServiceTypeId = mappingexcel.ServiceTypeId; await _dbTeleBilling_V01Context.AddAsync(mappingexcelCommon); await _dbTeleBilling_V01Context.SaveChangesAsync(); } #endregion } } #region --> Update Mapping column Details if (excelMappingAC.dbfieldList.Count() > 0) { #region --> remove old Mapping List <Mappingexcelcolumn> excelcolumnlst = new List <Mappingexcelcolumn>(); excelcolumnlst = await _dbTeleBilling_V01Context.Mappingexcelcolumn.Where(x => x.MappingExcelId == mappingexcel.Id).ToListAsync(); if (excelcolumnlst != null) { _dbTeleBilling_V01Context.RemoveRange(excelcolumnlst); await _dbTeleBilling_V01Context.SaveChangesAsync(); } #endregion List <Mappingexcelcolumn> mappingExcelColumnslst = new List <Mappingexcelcolumn>(); foreach (var item in excelMappingAC.dbfieldList) { if (!string.IsNullOrEmpty(item.ColumnAddress)) { Mappingexcelcolumn excelColumn = new Mappingexcelcolumn(); excelColumn.MappingExcelId = mappingexcel.Id; excelColumn.MappingServiceTypeFieldId = item.Id; excelColumn.ExcelcolumnName = item.ColumnAddress; excelColumn.FormatField = item.FormatField; mappingExcelColumnslst.Add(excelColumn); } } await _dbTeleBilling_V01Context.AddRangeAsync(mappingExcelColumnslst); await _dbTeleBilling_V01Context.SaveChangesAsync(); responeAC.Message = _iStringConstant.ExcelMappingUpdatedSuccessfully; responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Success); } #endregion } } else { responeAC.Message = _iStringConstant.DataFound; responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Error); } return(responeAC); } catch (Exception e) { responeAC.Message = e.Message.ToString(); responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Error); return(responeAC); } }
public async Task <ExcelMappingAC> GetExcelMappingById(long excelMappingId) { try { ExcelMappingAC excelMapping = new ExcelMappingAC(); Mappingexcel mapExcels = new Mappingexcel(); var mappingData = await _dbTeleBilling_V01Context.Mappingexcel.FirstOrDefaultAsync(x => x.Id == excelMappingId); var mapExcel = await _dbTeleBilling_V01Context.Mappingexcel.Include(x => x.Provider).Include(x => x.ServiceType).FirstOrDefaultAsync(x => x.Id == excelMappingId); if (mapExcel != null) { excelMapping.Id = mapExcel.Id; excelMapping.Provider = mapExcel.Provider.Name; excelMapping.ServiceType = mapExcel.ServiceType.Name; excelMapping.ProviderId = mapExcel.ProviderId; excelMapping.ServiceTypeId = mapExcel.ServiceTypeId; excelMapping.HaveHeader = mapExcel.HaveHeader; excelMapping.HaveTitle = mapExcel.HaveTitle; excelMapping.TitleName = mapExcel.TitleName; excelMapping.WorkSheetNo = mapExcel.WorkSheetNo; excelMapping.ExcelColumnNameForTitle = mapExcel.ExcelColumnNameForTitle; excelMapping.ExcelReadingColumn = mapExcel.ExcelReadingColumn; List <Mappingexcel> CommonMappingData = new List <Mappingexcel>(); CommonMappingData = await _dbTeleBilling_V01Context.Mappingexcel.Include(x => x.ServiceType).Where(x => x.MappedMappingId == excelMappingId && x.MappedServiceTypeId == mapExcel.ServiceTypeId && x.IsCommonMapped == true).ToListAsync(); if (CommonMappingData != null) { if (CommonMappingData.Count() > 0) { string joined = string.Join(",", CommonMappingData.Select(x => x.ServiceType.Name).ToArray()); var ServiceTypeIdInline = from pro in CommonMappingData select new DrpResponseAC() { Name = pro.ServiceType.Name, Id = pro.ServiceType.Id }; excelMapping.ServiceTypeIdInline = ServiceTypeIdInline.ToList(); excelMapping.ServiceTypesInline = joined; } } List <MappingServiceTypeFieldAC> dbfieldlst = new List <MappingServiceTypeFieldAC>(); List <Mappingservicetypefield> lstofMappingServiceType = await _dbTeleBilling_V01Context.Mappingservicetypefield.Where(x => x.ServiceTypeId == mapExcel.ServiceTypeId).ToListAsync(); List <Mappingexcelcolumn> mapexcelcolumn = await _dbTeleBilling_V01Context.Mappingexcelcolumn.Where(x => x.MappingExcelId == excelMappingId).ToListAsync(); foreach (var item in lstofMappingServiceType) { MappingServiceTypeFieldAC dbfield = new MappingServiceTypeFieldAC(); var objMapexcelcolumn = mapexcelcolumn.FirstOrDefault(x => x.MappingServiceTypeFieldId == item.Id); if (objMapexcelcolumn != null) { dbfield.ColumnAddress = objMapexcelcolumn.ExcelcolumnName; dbfield.FormatField = objMapexcelcolumn.FormatField; } dbfield.Id = item.Id; dbfield.DisplayFieldName = item.DisplayFieldName; dbfield.IsRequired = item.IsRequired; dbfield.IsSpecial = item.IsSpecial; dbfieldlst.Add(dbfield); } excelMapping.dbfieldList = dbfieldlst; return(excelMapping); } } catch (Exception e) { return(new ExcelMappingAC()); } return(new ExcelMappingAC()); }
public async Task <ResponseAC> AddExcelMapping(ExcelMappingAC excelMappingAC, long userId, string loginUserName) { ResponseAC responeAC = new ResponseAC(); try { if (excelMappingAC.dbfieldList.Count() == 0) { responeAC.Message = "Mapping Column Is Missing"; responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Error); return(responeAC); } if (excelMappingAC != null) { bool IsExistsServices = false; IsExistsServices = await checkExcelMappingExistsForServices(excelMappingAC); if (IsExistsServices) { responeAC.Message = "excel mapping is already exists"; responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Error); return(responeAC); } } if ((await _dbTeleBilling_V01Context.Mappingexcel.FirstOrDefaultAsync(x => x.ProviderId == excelMappingAC.ProviderId && x.ServiceTypeId == excelMappingAC.ServiceTypeId && !x.IsDelete)) == null) { var providerData = await _dbTeleBilling_V01Context.Provider.FirstOrDefaultAsync(x => x.Id == excelMappingAC.ProviderId); Mappingexcel mappingexcel = new Mappingexcel(); mappingexcel.Id = 0; mappingexcel.IsActive = true; mappingexcel.ProviderId = excelMappingAC.ProviderId; mappingexcel.CurrencyId = providerData.CurrencyId; mappingexcel.ServiceTypeId = excelMappingAC.ServiceTypeId; mappingexcel.HaveHeader = excelMappingAC.HaveHeader; mappingexcel.HaveTitle = excelMappingAC.HaveTitle; mappingexcel.TitleName = excelMappingAC.TitleName; mappingexcel.WorkSheetNo = Convert.ToInt64(excelMappingAC.WorkSheetNo); mappingexcel.ExcelColumnNameForTitle = string.IsNullOrEmpty(excelMappingAC.ExcelColumnNameForTitle) ? "" : excelMappingAC.ExcelColumnNameForTitle; mappingexcel.ExcelReadingColumn = string.IsNullOrEmpty(excelMappingAC.ExcelReadingColumn) ? "0" : excelMappingAC.ExcelReadingColumn; mappingexcel.CreatedBy = userId; mappingexcel.CreatedDate = DateTime.Now; mappingexcel.IsCommonMapped = false; mappingexcel.MappedMappingId = 0; mappingexcel.MappedServiceTypeId = 0; mappingexcel.IsDelete = false; mappingexcel.TransactionId = _iLogManagement.GenerateTeleBillingTransctionID(); await _dbTeleBilling_V01Context.AddAsync(mappingexcel); await _dbTeleBilling_V01Context.SaveChangesAsync(); responeAC.Message = _iStringConstant.ExcelMappingAddedSuccessfully; responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Success); await _iLogManagement.SaveAuditActionLog((int)EnumList.AuditLogActionType.AddExcelMapping, loginUserName, userId, "Excel mapping", (int)EnumList.ActionTemplateTypes.Add, mappingexcel.Id); if (mappingexcel.Id > 0) { #region ---> Add Common Servive if exists foreach (var serviceType in excelMappingAC.ServiceTypeIdInline) { Mappingexcel mappingexcelCommon = new Mappingexcel(); mappingexcelCommon.Id = 0; mappingexcelCommon.IsActive = true; mappingexcelCommon.ProviderId = excelMappingAC.ProviderId; mappingexcelCommon.CurrencyId = providerData.CurrencyId; mappingexcelCommon.ServiceTypeId = serviceType.Id; mappingexcelCommon.HaveHeader = excelMappingAC.HaveHeader; mappingexcelCommon.HaveTitle = excelMappingAC.HaveTitle; mappingexcelCommon.TitleName = excelMappingAC.TitleName; mappingexcelCommon.WorkSheetNo = Convert.ToInt64(excelMappingAC.WorkSheetNo); mappingexcelCommon.ExcelColumnNameForTitle = excelMappingAC.ExcelColumnNameForTitle; mappingexcelCommon.ExcelReadingColumn = string.IsNullOrEmpty(excelMappingAC.ExcelReadingColumn) ? "" : excelMappingAC.ExcelReadingColumn; mappingexcelCommon.CreatedBy = userId; mappingexcelCommon.CreatedDate = DateTime.Now; mappingexcelCommon.TransactionId = mappingexcel.TransactionId; mappingexcelCommon.IsCommonMapped = true; mappingexcelCommon.MappedMappingId = mappingexcel.Id; mappingexcelCommon.MappedServiceTypeId = mappingexcel.ServiceTypeId; await _dbTeleBilling_V01Context.AddAsync(mappingexcelCommon); await _dbTeleBilling_V01Context.SaveChangesAsync(); } #endregion #region --> ADD Mapping column Details if (excelMappingAC.dbfieldList.Count() > 0) { List <Mappingexcelcolumn> mappingExcelColumnslst = new List <Mappingexcelcolumn>(); foreach (var item in excelMappingAC.dbfieldList) { if (!string.IsNullOrEmpty(item.ColumnAddress)) { Mappingexcelcolumn excelColumn = new Mappingexcelcolumn(); excelColumn.MappingExcelId = mappingexcel.Id; excelColumn.MappingServiceTypeFieldId = item.Id; excelColumn.ExcelcolumnName = item.ColumnAddress; excelColumn.FormatField = item.FormatField; mappingExcelColumnslst.Add(excelColumn); } } await _dbTeleBilling_V01Context.AddRangeAsync(mappingExcelColumnslst); await _dbTeleBilling_V01Context.SaveChangesAsync(); responeAC.Message = _iStringConstant.ExcelMappingAddedSuccessfully; responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Success); } #endregion } } else { responeAC.Message = _iStringConstant.ExcelMappingExists; responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Error); } return(responeAC); } catch (Exception e) { responeAC.Message = e.Message.ToString(); responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Error); return(responeAC); } }