public async Task <ProviderAC> GetProviderById(long id)
        {
            ProviderAC providerAC = new ProviderAC();

            TeleBillingUtility.Models.Provider provider = await _dbTeleBilling_V01Context.Provider.FirstAsync(x => x.Id == id);

            providerAC = _mapper.Map <ProviderAC>(provider);

            List <Providerservice> listOfService = await _dbTeleBilling_V01Context.Providerservice.Where(x => x.ProviderId == id && !x.IsDelete).Include(x => x.ServiceType).ToListAsync();

            providerAC.ServiceTypes = new List <DrpResponseAC>();
            foreach (var item in listOfService)
            {
                DrpResponseAC serviceType = new DrpResponseAC();
                serviceType.Id   = item.ServiceTypeId;
                serviceType.Name = item.ServiceType.Name;

                providerAC.ServiceTypes.Add(serviceType);
            }

            List <Providercontactdetail> providerContactDetails = await _dbTeleBilling_V01Context.Providercontactdetail.Where(x => x.ProviderId == provider.Id && !x.IsDeleted).ToListAsync();

            providerAC.ProviderContactDetailACList = new List <ProviderContactDetailAC>();
            providerAC.ProviderContactDetailACList = _mapper.Map(providerContactDetails, providerAC.ProviderContactDetailACList);

            return(providerAC);
        }
        public async Task <ResponseAC> AddProvider(long userId, ProviderAC providerAC, string loginUserName)
        {
            ResponseAC responeAC = new ResponseAC();

            if (!await _dbTeleBilling_V01Context.Provider.AnyAsync(x => x.ContractNumber.ToLower() == providerAC.ContractNumber.ToLower() && !x.IsDelete))
            {
                TeleBillingUtility.Models.Provider provider = new TeleBillingUtility.Models.Provider();
                provider               = _mapper.Map <TeleBillingUtility.Models.Provider>(providerAC);
                provider.IsActive      = true;
                provider.CreatedDate   = DateTime.Now;
                provider.CreatedBy     = userId;
                provider.TransactionId = _iLogManagement.GenerateTeleBillingTransctionID();

                await _dbTeleBilling_V01Context.AddAsync(provider);

                await _dbTeleBilling_V01Context.SaveChangesAsync();


                foreach (var serviceType in providerAC.ServiceTypes)
                {
                    Providerservice providerService = new Providerservice();
                    providerService.ProviderId    = provider.Id;
                    providerService.ServiceTypeId = serviceType.Id;
                    await _dbTeleBilling_V01Context.AddAsync(providerService);

                    await _dbTeleBilling_V01Context.SaveChangesAsync();
                }

                #region Added Provider Contact Detail
                List <Providercontactdetail> providerContactDetails = new List <Providercontactdetail>();
                foreach (var item in providerAC.ProviderContactDetailACList)
                {
                    Providercontactdetail providerContectDatail = new Providercontactdetail();
                    providerContectDatail            = _mapper.Map <Providercontactdetail>(item);
                    providerContectDatail.ProviderId = provider.Id;
                    providerContactDetails.Add(providerContectDatail);
                }

                await _dbTeleBilling_V01Context.AddRangeAsync(providerContactDetails);

                await _dbTeleBilling_V01Context.SaveChangesAsync();

                #endregion

                await _iLogManagement.SaveAuditActionLog((int)EnumList.AuditLogActionType.AddProvider, loginUserName, userId, "Provider(" + provider.Name + ")", (int)EnumList.ActionTemplateTypes.Add, provider.Id);

                responeAC.Message    = _iStringConstant.ProviderAddedSuccessfully;
                responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Success);
            }
            else
            {
                responeAC.Message    = _iStringConstant.ContractNumberExists;
                responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Error);
            }
            return(responeAC);
        }
        public async Task <MemoBillResponse> GetMemoBills(int month, int year, int providerid)
        {
            long             billStatusId    = Convert.ToInt16(EnumList.BillStatus.BillClosed);
            MemoBillResponse memoBillRespons = new MemoBillResponse();

            TeleBillingUtility.Models.Provider provider = await _dbTeleBilling_V01Context.Provider.FirstOrDefaultAsync(x => x.Id == providerid);

            if (provider != null)
            {
                memoBillRespons.Ibancode  = provider.Ibancode;
                memoBillRespons.Bank      = provider.Bank;
                memoBillRespons.Swiftcode = provider.Swiftcode;
            }

            List <Billmaster> billMasters = await _dbTeleBilling_V01Context.Billmaster.Where(x => !x.IsDelete && x.BillStatusId == billStatusId && x.BillMonth == month && x.BillYear == year && x.ProviderId == providerid).ToListAsync();

            memoBillRespons.MemoBills = _mapper.Map <List <MemoBillsAC> >(billMasters);
            return(memoBillRespons);
        }
        public async Task <bool> DeleteProvider(long userId, long id, string loginUserName)
        {
            TeleBillingUtility.Models.Provider provider = await _dbTeleBilling_V01Context.Provider.FirstOrDefaultAsync(x => x.Id == id);

            SortedList sl = new SortedList();

            sl.Add("p_ProviderId", id);
            int result = Convert.ToInt16(_objDalmysql.ExecuteScaler("usp_GetProviderExists", sl));

            if (result == 0)
            {
                provider.IsDelete    = true;
                provider.UpdatedBy   = userId;
                provider.UpdatedDate = DateTime.Now;
                _dbTeleBilling_V01Context.Update(provider);
                await _dbTeleBilling_V01Context.SaveChangesAsync();

                await _iLogManagement.SaveAuditActionLog((int)EnumList.AuditLogActionType.DeleteProvider, loginUserName, userId, "Provider(" + provider.Name + ")", (int)EnumList.ActionTemplateTypes.Delete, provider.Id);

                return(true);
            }
            return(false);
        }
        public async Task <bool> ChangeProviderStatus(long userId, long id, string loginUserName)
        {
            TeleBillingUtility.Models.Provider provider = await _dbTeleBilling_V01Context.Provider.FirstOrDefaultAsync(x => x.Id == id);

            if (provider != null)
            {
                #region Transaction Log Entry
                if (provider.TransactionId == null)
                {
                    provider.TransactionId = _iLogManagement.GenerateTeleBillingTransctionID();
                }

                var jsonSerailzeObj = JsonConvert.SerializeObject(provider);
                await _iLogManagement.SaveRequestTraseLog(Convert.ToInt64(provider.TransactionId), userId, Convert.ToInt64(EnumList.TransactionTraseLog.ChangeStatus), jsonSerailzeObj);

                #endregion

                provider.IsActive    = !provider.IsActive;
                provider.UpdatedBy   = userId;
                provider.UpdatedDate = DateTime.Now;
                _dbTeleBilling_V01Context.Update(provider);
                await _dbTeleBilling_V01Context.SaveChangesAsync();

                if (provider.IsActive)
                {
                    await _iLogManagement.SaveAuditActionLog((int)EnumList.AuditLogActionType.ActiveProvider, loginUserName, userId, "Provider(" + provider.Name + ")", (int)EnumList.ActionTemplateTypes.Active, provider.Id);
                }
                else
                {
                    await _iLogManagement.SaveAuditActionLog((int)EnumList.AuditLogActionType.DeactiveProvider, loginUserName, userId, "Provider(" + provider.Name + ")", (int)EnumList.ActionTemplateTypes.Deactive, provider.Id);
                }

                return(true);
            }
            return(false);
        }
Beispiel #6
0
        public async Task <BulkAssignTelephoneResponseAC> BulkUploadOperatorCallLog(long userId, ExcelUploadResponseAC exceluploadDetail, string loginUserName)
        {
            BulkAssignTelephoneResponseAC bulkAssignTelephoneResponseAC = new BulkAssignTelephoneResponseAC();
            List <ExcelUploadResult>      excelUploadResultList         = new List <ExcelUploadResult>();
            List <Operatorcalllog>        operatorCallLogList           = new List <Operatorcalllog>();
            FileInfo fileinfo = new FileInfo(Path.Combine(exceluploadDetail.FilePath, exceluploadDetail.FileNameGuid));

            try
            {
                using (ExcelPackage package = new ExcelPackage(fileinfo))
                {
                    for (int i = 1; i <= package.Workbook.Worksheets.Count(); i++)
                    {
                        ExcelWorksheet workSheet = package.Workbook.Worksheets[i];
                        if (workSheet != null)
                        {
                            string sheetName   = workSheet.Name;
                            int    totalRows   = workSheet.Dimension.Rows;
                            int    totalColums = workSheet.Dimension.Columns;
                            for (int j = 1; j <= totalRows - 1; j++)
                            {
                                Operatorcalllog operatorCallLog = new Operatorcalllog();
                                bulkAssignTelephoneResponseAC.TotalRecords += 1;
                                string callDate = workSheet.Cells[j + 1, 1].Value != null ? workSheet.Cells[j + 1, 1].Value.ToString() : string.Empty;
                                if (!string.IsNullOrEmpty(callDate))
                                {
                                    DateTime newCallDate;
                                    if (DateTime.TryParse(callDate, out newCallDate))
                                    {
                                        String.Format("{0:d/MM/yyyy}", newCallDate);
                                        string pfNumber = workSheet.Cells[j + 1, 2].Value != null ? workSheet.Cells[j + 1, 2].Value.ToString() : string.Empty;
                                        pfNumber = !string.IsNullOrEmpty(pfNumber) ? pfNumber.ToLower().Trim() : string.Empty;
                                        MstEmployee mstEmployee = await _dbTeleBilling_V01Context.MstEmployee.FirstOrDefaultAsync(x => x.IsActive && !x.IsDelete && x.EmpPfnumber.ToLower().Trim() == pfNumber);

                                        if (mstEmployee != null)
                                        {
                                            string telephoneNumber = workSheet.Cells[j + 1, 3].Value != null ? workSheet.Cells[j + 1, 3].Value.ToString() : string.Empty;
                                            if (!string.IsNullOrEmpty(telephoneNumber))
                                            {
                                                if (telephoneNumber.Length < 50)
                                                {
                                                    string provider = workSheet.Cells[j + 1, 4].Value != null ? workSheet.Cells[j + 1, 4].Value.ToString() : string.Empty;
                                                    provider = !string.IsNullOrEmpty(provider) ? provider.ToLower().Trim() : string.Empty;
                                                    TeleBillingUtility.Models.Provider providerObj = await _dbTeleBilling_V01Context.Provider.FirstOrDefaultAsync(x => x.IsActive && !x.IsDelete && x.Name.ToLower().Trim() == provider);

                                                    if (providerObj != null)
                                                    {
                                                        string callType = workSheet.Cells[j + 1, 5].Value != null ? workSheet.Cells[j + 1, 5].Value.ToString() : string.Empty;
                                                        callType = !string.IsNullOrEmpty(callType) ? callType.ToLower().Trim() : string.Empty;
                                                        FixCalltype callTypeObj = await _dbTeleBilling_V01Context.FixCalltype.FirstOrDefaultAsync(x => x.IsActive && x.Name.ToLower().Trim() == callType);

                                                        if (callTypeObj != null)
                                                        {
                                                            operatorCallLog.CallDate        = newCallDate;
                                                            operatorCallLog.CallTypeId      = callTypeObj.Id;
                                                            operatorCallLog.ProviderId      = providerObj.Id;
                                                            operatorCallLog.EmployeeId      = mstEmployee.UserId;
                                                            operatorCallLog.EmpPfnumber     = mstEmployee.EmpPfnumber;
                                                            operatorCallLog.ExtensionNumber = mstEmployee.ExtensionNumber;
                                                            operatorCallLog.TransactionId   = _iLogManagement.GenerateTeleBillingTransctionID();
                                                            operatorCallLog.DialedNumber    = telephoneNumber;
                                                            operatorCallLog.CreatedBy       = userId;
                                                            operatorCallLog.CreatedDate     = DateTime.Now;
                                                            operatorCallLogList.Add(operatorCallLog);
                                                            bulkAssignTelephoneResponseAC.SuccessRecords += 1;
                                                        }
                                                        else
                                                        {
                                                            //Call Type Not Exists
                                                            bulkAssignTelephoneResponseAC.SkipRecords += 1;
                                                            excelUploadResultList = AddedFileDataResponse(4, j, callType, _iStringConstant.CallTypeNotExists, sheetName, excelUploadResultList);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        //Provider Not Exists
                                                        bulkAssignTelephoneResponseAC.SkipRecords += 1;
                                                        excelUploadResultList = AddedFileDataResponse(4, j, provider, _iStringConstant.ProviderNotExists, sheetName, excelUploadResultList);
                                                    }
                                                }
                                                else
                                                {
                                                    //Telephone Number length
                                                    bulkAssignTelephoneResponseAC.SkipRecords += 1;
                                                    excelUploadResultList = AddedFileDataResponse(3, j, telephoneNumber, _iStringConstant.TelePhoneNumberMaxLength, sheetName, excelUploadResultList);
                                                }
                                            }
                                            else
                                            {
                                                //Telephone number is empty
                                                bulkAssignTelephoneResponseAC.SkipRecords += 1;
                                                excelUploadResultList = AddedFileDataResponse(3, j, telephoneNumber, _iStringConstant.TelePhoneNumberIsEmpty, sheetName, excelUploadResultList);
                                            }
                                        }
                                        else
                                        {
                                            //Employee Not Exists
                                            bulkAssignTelephoneResponseAC.SkipRecords += 1;
                                            excelUploadResultList = AddedFileDataResponse(2, j, pfNumber, _iStringConstant.EmployeeNotExists, sheetName, excelUploadResultList);
                                        }
                                    }
                                    else
                                    {
                                        //Start Date Not Valid
                                        bulkAssignTelephoneResponseAC.SkipRecords += 1;
                                        excelUploadResultList = AddedFileDataResponse(1, j + 1, callDate, _iStringConstant.CallDateNotValid, sheetName, excelUploadResultList);
                                    }
                                }
                                else
                                {       //Call Date Is Empty
                                    bulkAssignTelephoneResponseAC.SkipRecords += 1;
                                    excelUploadResultList = AddedFileDataResponse(1, j, callDate, _iStringConstant.CallDateIsEmpty, sheetName, excelUploadResultList);
                                }
                            }
                        }
                    }
                }
                if (File.Exists(Path.Combine(exceluploadDetail.FilePath, exceluploadDetail.FileNameGuid)))
                {
                    File.Delete(Path.Combine(exceluploadDetail.FilePath, exceluploadDetail.FileNameGuid));
                }

                if (operatorCallLogList.Any())
                {
                    await _dbTeleBilling_V01Context.AddRangeAsync(operatorCallLogList);

                    await _dbTeleBilling_V01Context.SaveChangesAsync();

                    await _iLogManagement.SaveAuditActionLog((int)EnumList.AuditLogActionType.BulkUploadOperatorCallLog, loginUserName, userId, "Bulk Operator call log", (int)EnumList.ActionTemplateTypes.Upload, null);
                }
                bulkAssignTelephoneResponseAC.excelUploadResultList = excelUploadResultList;
                return(bulkAssignTelephoneResponseAC);
            }
            catch (Exception ex)
            {
                if (File.Exists(Path.Combine(exceluploadDetail.FilePath, exceluploadDetail.FileNameGuid)))
                {
                    File.Delete(Path.Combine(exceluploadDetail.FilePath, exceluploadDetail.FileNameGuid));
                }
                throw ex;
            }
        }
        public async Task <ResponseAC> UpdateProvider(long userId, ProviderAC providerAC, string loginUserName)
        {
            ResponseAC responeAC = new ResponseAC();

            if (await _dbTeleBilling_V01Context.Provider.FirstOrDefaultAsync(x => x.Id != providerAC.Id && x.ContractNumber.ToLower() == providerAC.ContractNumber.ToLower() && !x.IsDelete) == null)
            {
                TeleBillingUtility.Models.Provider provider = await _dbTeleBilling_V01Context.Provider.FirstOrDefaultAsync(x => x.Id == providerAC.Id);

                if (provider != null)
                {
                    #region Transaction Log Entry
                    if (provider.TransactionId == null)
                    {
                        provider.TransactionId = _iLogManagement.GenerateTeleBillingTransctionID();
                    }

                    var jsonSerailzeObj = JsonConvert.SerializeObject(provider);
                    await _iLogManagement.SaveRequestTraseLog(Convert.ToInt64(provider.TransactionId), userId, Convert.ToInt64(EnumList.TransactionTraseLog.UpdateRecord), jsonSerailzeObj);

                    #endregion

                    provider             = _mapper.Map(providerAC, provider);
                    provider.UpdatedBy   = userId;
                    provider.UpdatedDate = DateTime.Now;

                    _dbTeleBilling_V01Context.Update(provider);
                    await _dbTeleBilling_V01Context.SaveChangesAsync();

                    #region Update Provider Service List
                    List <Providerservice> providerServiceList = await _dbTeleBilling_V01Context.Providerservice.Where(x => x.ProviderId == providerAC.Id && !x.IsDelete).ToListAsync();

                    if (providerServiceList.Any())
                    {
                        List <Providerservice> dummyProviderServices = new List <Providerservice>();
                        foreach (var item in providerServiceList)
                        {
                            item.IsDelete = true;
                            dummyProviderServices.Add(item);
                        }

                        _dbTeleBilling_V01Context.UpdateRange(dummyProviderServices);
                        _dbTeleBilling_V01Context.SaveChanges();
                    }

                    providerServiceList = new List <Providerservice>();
                    foreach (var serviceType in providerAC.ServiceTypes)
                    {
                        Providerservice providerService = new Providerservice();
                        providerService.ServiceTypeId = serviceType.Id;
                        providerService.ProviderId    = providerAC.Id;
                        providerServiceList.Add(providerService);
                    }

                    await _iLogManagement.SaveAuditActionLog((int)EnumList.AuditLogActionType.EditProvider, loginUserName, userId, "Provider(" + provider.Name + ")", (int)EnumList.ActionTemplateTypes.Edit, provider.Id);

                    await _dbTeleBilling_V01Context.AddRangeAsync(providerServiceList);

                    await _dbTeleBilling_V01Context.SaveChangesAsync();

                    #endregion

                    #region Update Provider Contact Details
                    List <Providercontactdetail> providerContactDetails = await _dbTeleBilling_V01Context.Providercontactdetail.Where(x => x.ProviderId == provider.Id && !x.IsDeleted).ToListAsync();

                    if (providerContactDetails.Any())
                    {
                        List <Providercontactdetail> providerContactDetailList = new List <Providercontactdetail>();
                        foreach (var providerContact in providerContactDetails)
                        {
                            providerContact.IsDeleted = true;
                            providerContactDetailList.Add(providerContact);
                        }
                    }


                    #region Added Provider Contact Detail
                    providerContactDetails = new List <Providercontactdetail>();
                    foreach (var item in providerAC.ProviderContactDetailACList)
                    {
                        Providercontactdetail providerContectDatail = new Providercontactdetail();
                        providerContectDatail            = _mapper.Map <Providercontactdetail>(item);
                        providerContectDatail.Id         = 0;
                        providerContectDatail.ProviderId = provider.Id;
                        providerContactDetails.Add(providerContectDatail);
                    }

                    await _dbTeleBilling_V01Context.AddRangeAsync(providerContactDetails);

                    await _dbTeleBilling_V01Context.SaveChangesAsync();

                    #endregion

                    #endregion

                    responeAC.Message    = _iStringConstant.ProviderUpdatedSuccessfully;
                    responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Success);
                }
            }
            else
            {
                responeAC.Message    = _iStringConstant.ContractNumberExists;
                responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Error);
            }
            return(responeAC);
        }