public async Task <ResponseAC> UpdateAssignedTelephone(long userId, AssignTelephoneDetailAC assignTelephoneDetailAC, string loginUserName)
        {
            ResponseAC responseAC = new ResponseAC();
            Telephonenumberallocation telephoneNumberAllocation = await _dbTeleBilling_V01Context.Telephonenumberallocation.FirstAsync(x => x.Id == assignTelephoneDetailAC.Id);

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

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

            #endregion

            telephoneNumberAllocation             = _mapper.Map(assignTelephoneDetailAC, telephoneNumberAllocation);
            telephoneNumberAllocation.UpdatedBy   = userId;
            telephoneNumberAllocation.UpdatedDate = DateTime.Now;

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

            List <Telephonenumberallocationpackage> telePhoneNumberAllocationPackages = await _dbTeleBilling_V01Context.Telephonenumberallocationpackage.Where(x => x.TelephoneNumberAllocationId == telephoneNumberAllocation.Id && !x.IsDelete).ToListAsync();

            foreach (var item in telePhoneNumberAllocationPackages)
            {
                item.IsDelete    = true;
                item.UpdatedBy   = userId;
                item.UpdatedDate = DateTime.Now;
            }

            _dbTeleBilling_V01Context.UpdateRange(telePhoneNumberAllocationPackages);
            _dbTeleBilling_V01Context.SaveChanges();

            #region Update Packages
            telePhoneNumberAllocationPackages = new List <Telephonenumberallocationpackage>();
            foreach (var item in assignTelephoneDetailAC.TelePhonePackageDetails)
            {
                Telephonenumberallocationpackage telePhoneNumberAllocationPackage = new Telephonenumberallocationpackage();
                telePhoneNumberAllocationPackage.PackageId = item.PackageId;
                telePhoneNumberAllocationPackage.ServiceId = item.ServiceId;
                telePhoneNumberAllocationPackage.StartDate = item.StartDate.AddDays(1);
                telePhoneNumberAllocationPackage.EndDate   = item.EndDate.AddDays(1);
                telePhoneNumberAllocationPackage.TelephoneNumberAllocationId = telephoneNumberAllocation.Id;
                telePhoneNumberAllocationPackages.Add(telePhoneNumberAllocationPackage);
            }
            await _dbTeleBilling_V01Context.AddRangeAsync(telePhoneNumberAllocationPackages);

            await _dbTeleBilling_V01Context.SaveChangesAsync();

            #endregion

            await _iLogManagement.SaveAuditActionLog((int)EnumList.AuditLogActionType.EditAssignTelephone, loginUserName, userId, "Assign Telephone(" + telephoneNumberAllocation.TelephoneNumber + ")", (int)EnumList.ActionTemplateTypes.Edit, telephoneNumberAllocation.Id);

            responseAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Success);
            responseAC.Message    = _iStringConstant.AssignedTelePhoneEditSuccessfully;
            return(responseAC);
        }
        public async Task <ResponseAC> UpdateRoleRights(long userId, List <RoleRightsAC> roleRightsACList, string loginUserName)
        {
            ResponseAC           responseAc = new ResponseAC();
            long                 roleId     = roleRightsACList[0].RoleId;
            List <MstRolerights> roleRights = await _dbTeleBilling_V01Context.MstRolerights.Where(x => x.RoleId == roleId).Include(x => x.Role).ToListAsync();

            int     actionId = (int)EnumList.ActionTemplateTypes.Add;
            MstRole role     = new MstRole();

            role = await _dbTeleBilling_V01Context.MstRole.FindAsync(roleId);

            if (roleRights.Any())
            {
                //#region Transaction Log Entry
                //var jsonSerailzeObj = JsonConvert.SerializeObject(roleRights);
                //await _iLogManagement.SaveRequestTraseLog(Convert.ToInt64(roleRights[0].TransactionId), userId, Convert.ToInt64(EnumList.TransactionTraseLog.UpdateRecord), jsonSerailzeObj);
                //#endregion

                _dbTeleBilling_V01Context.MstRolerights.RemoveRange(roleRights);
                _dbTeleBilling_V01Context.SaveChanges();

                actionId = (int)EnumList.ActionTemplateTypes.Edit;
            }

            roleRights = new List <MstRolerights>();
            foreach (var item in roleRightsACList)
            {
                MstRolerights newRoleRights = new MstRolerights();
                newRoleRights               = _mapper.Map <MstRolerights>(item);
                newRoleRights.CreatedBy     = userId;
                newRoleRights.TransactionId = _iLogManagement.GenerateTeleBillingTransctionID();
                newRoleRights.CreatedDate   = DateTime.Now;
                roleRights.Add(newRoleRights);
            }
            await _dbTeleBilling_V01Context.MstRolerights.AddRangeAsync(roleRights);

            _dbTeleBilling_V01Context.SaveChanges();
            responseAc.Message    = _iStringConstant.RoleRightsUpdatedSuccessfully;
            responseAc.StatusCode = Convert.ToInt16(EnumList.ResponseType.Success);
            await _iLogManagement.SaveAuditActionLog((int)EnumList.AuditLogActionType.ChangeRoleRights, loginUserName, userId, "Rolerights(" + Convert.ToString(role.RoleName) + ")", actionId, null);

            return(responseAc);
        }
Example #3
0
        /// <summary>
        /// This method used for added reminder notification log
        /// </summary>
        /// <param name="emailTemplateId"></param>
        /// <param name="employeeBillId"></param>
        /// <param name="isReminderMail"></param>
        private void AddedReminderNotificationLog(long emailTemplateId, long employeeBillId, bool isReminderMail, string emailTo)
        {
            using (var _dbTeleBillingContext = new telebilling_v01Context())
            {
                Emailreminderlog newEmailReminderLog = new Emailreminderlog();
                newEmailReminderLog.CreatedDate    = DateTime.Now;
                newEmailReminderLog.IsReminderMail = isReminderMail;
                newEmailReminderLog.TemplateId     = emailTemplateId;
                newEmailReminderLog.EmailTo        = string.IsNullOrEmpty(emailTo) ? string.Empty : emailTo;
                newEmailReminderLog.EmployeeBillId = employeeBillId;

                _dbTeleBillingContext.Add(newEmailReminderLog);
                _dbTeleBillingContext.SaveChanges();
            }
        }
        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);
        }
Example #5
0
        void timerBillClosed_Elapsed(object sender, ElapsedEventArgs e)
        {
            using (var _dbTeleBillingContext = new telebilling_v01Context())
            {
                try
                {
                    int billAllocatedStatusId     = Convert.ToInt16(EnumList.BillStatus.BillAllocated);
                    List <Billmaster> billMasters = _dbTeleBillingContext.Billmaster.Where(x => !x.IsDelete && (x.BillStatusId == billAllocatedStatusId)).ToList();
                    if (billMasters.Any())
                    {
                        foreach (var item in billMasters)
                        {
                            if (item.BillDueDate != null)
                            {
                                if (Convert.ToDateTime(item.BillDueDate).Date < DateTime.Now.Date)
                                {
                                    int billCloseStatusId         = Convert.ToInt16(EnumList.EmployeeBillStatus.CloseBill);
                                    int billAutoCloseBillStatusId = Convert.ToInt16(EnumList.EmployeeBillStatus.AutoCloseBill);
                                    List <Employeebillmaster> employeeBillMasters = _dbTeleBillingContext.Employeebillmaster.Where(x => x.BillMasterId == item.Id && !x.IsDelete && (x.EmployeeBillStatus != billCloseStatusId && x.EmployeeBillStatus != billAutoCloseBillStatusId)).Include(x => x.Employee).Include(x => x.Provider).ToList();
                                    List <Notificationlog>    notificationlogs    = new List <Notificationlog>();
                                    if (employeeBillMasters.Any())
                                    {
                                        foreach (var subItem in employeeBillMasters)
                                        {
                                            #region Transaction Log Entry

                                            if (subItem.TransactionId == null)
                                            {
                                                subItem.TransactionId = GenerateTeleBillingTransctionID();
                                            }

                                            //var jsonSerailzeObj = JsonConvert.SerializeObject(subItem);

                                            //SaveRequestTraseLog(Convert.ToInt64(subItem.TransactionId), 0, Convert.ToInt64(EnumList.TransactionTraseLog.BillClosed), jsonSerailzeObj);
                                            #endregion

                                            List <Employeebillservicepackage> employeeBillServicePackages = _dbTeleBillingContext.Employeebillservicepackage.Where(x => x.EmployeeBillId == subItem.Id && !x.IsDelete).Include(x => x.Package).ToList();
                                            foreach (var employeeBillServicePackage in employeeBillServicePackages)
                                            {
                                                if (!subItem.Employee.IsPresidentOffice)
                                                {
                                                    if (string.IsNullOrEmpty(subItem.TelephoneNumber))                                                    //For Skyp
                                                    {
                                                        //for service landline or voip
                                                        if (employeeBillServicePackage.ServiceTypeId == Convert.ToInt64(EnumList.ServiceType.VOIP) || employeeBillServicePackage.ServiceTypeId == Convert.ToInt64(EnumList.ServiceType.MOC))
                                                        {
                                                            if (subItem.EmployeeBillStatus == Convert.ToInt16(EnumList.EmployeeBillStatus.WaitingForIdentification) || subItem.EmployeeBillStatus == Convert.ToInt16(EnumList.EmployeeBillStatus.BillReject))
                                                            {
                                                                List <Billdetails> billdetails       = _dbTeleBillingContext.Billdetails.Where(x => x.EmployeeBillId == subItem.Id && x.ServiceTypeId == employeeBillServicePackage.ServiceTypeId).ToList();
                                                                decimal            personalDeduction = 0;
                                                                decimal            businessCharge    = 0;
                                                                foreach (var subBillDetail in billdetails)
                                                                {
                                                                    if (subBillDetail.CallIdentificationType == Convert.ToInt16(EnumList.AssignType.Business))
                                                                    {
                                                                        businessCharge += subBillDetail.CallAmount != null?Convert.ToDecimal(subBillDetail.CallAmount) : 0;
                                                                    }
                                                                    else if (subBillDetail.CallIdentificationType == Convert.ToInt16(EnumList.AssignType.Employee))
                                                                    {
                                                                        personalDeduction += subBillDetail.CallAmount != null?Convert.ToDecimal(subBillDetail.CallAmount) : 0;
                                                                    }
                                                                }
                                                                employeeBillServicePackage.PersonalIdentificationAmount = personalDeduction;
                                                                employeeBillServicePackage.BusinessIdentificationAmount = businessCharge;
                                                                employeeBillServicePackage.DeductionAmount = personalDeduction;
                                                            }
                                                            else if (subItem.EmployeeBillStatus == Convert.ToInt16(EnumList.EmployeeBillStatus.WaitingForLineManagerApproval) || subItem.EmployeeBillStatus == Convert.ToInt16(EnumList.EmployeeBillStatus.LineManagerApproved))
                                                            {
                                                                employeeBillServicePackage.DeductionAmount = employeeBillServicePackage.PersonalIdentificationAmount;
                                                            }
                                                            SendEmailNotificationToEmployee(employeeBillServicePackage, subItem);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        var telephoneNumberAllocation = _dbTeleBillingContext.Telephonenumberallocation.FirstOrDefault(x => x.TelephoneNumber == subItem.TelephoneNumber && x.EmployeeId == subItem.EmployeeId && !x.IsDelete);
                                                        if (telephoneNumberAllocation.AssignTypeId != Convert.ToInt16(EnumList.AssignType.Business))
                                                        {
                                                            employeeBillServicePackage.DeductionAmount = 0;
                                                            List <Billdetails> billDetails = _dbTeleBillingContext.Billdetails.Where(x => x.EmployeeBillId == subItem.Id && x.ServiceTypeId == employeeBillServicePackage.ServiceTypeId).ToList();
                                                            decimal            totalAmount = billDetails.Sum(x => x.CallAmount).Value;

                                                            //for service landline
                                                            if (employeeBillServicePackage.ServiceTypeId == Convert.ToInt64(EnumList.ServiceType.LandLine) || employeeBillServicePackage.ServiceTypeId == Convert.ToInt64(EnumList.ServiceType.StaticIP))
                                                            {
                                                                //remaning
                                                                employeeBillServicePackage.DeductionAmount = employeeBillServicePackage.PersonalIdentificationAmount;
                                                                SendEmailNotificationToEmployee(employeeBillServicePackage, subItem);
                                                            }
                                                            else
                                                            {
                                                                if (subItem.EmployeeBillStatus == Convert.ToInt16(EnumList.EmployeeBillStatus.WaitingForIdentification) || subItem.EmployeeBillStatus == Convert.ToInt16(EnumList.EmployeeBillStatus.BillReject))
                                                                {
                                                                    if (employeeBillServicePackage.Package.PackageAmount < totalAmount)
                                                                    {
                                                                        decimal amount = 0;
                                                                        decimal businessIdentificationAmount = employeeBillServicePackage.BusinessIdentificationAmount != null?Convert.ToDecimal(employeeBillServicePackage.BusinessIdentificationAmount) : 0;

                                                                        if (employeeBillServicePackage.Package.PackageAmount < businessIdentificationAmount)
                                                                        {
                                                                            amount = businessIdentificationAmount;
                                                                        }
                                                                        else
                                                                        {
                                                                            amount = employeeBillServicePackage.Package.PackageAmount != null?Convert.ToDecimal(employeeBillServicePackage.Package.PackageAmount) : 0;
                                                                        }
                                                                        //BusinessIdentificationAmount alway less than or equal Package Amount
                                                                        employeeBillServicePackage.DeductionAmount = totalAmount - amount;
                                                                        SendEmailNotificationToEmployee(employeeBillServicePackage, subItem);
                                                                    }
                                                                    else
                                                                    {
                                                                        employeeBillServicePackage.DeductionAmount = 0;
                                                                    }
                                                                }
                                                                else if (subItem.EmployeeBillStatus == Convert.ToInt16(EnumList.EmployeeBillStatus.WaitingForLineManagerApproval) || subItem.EmployeeBillStatus == Convert.ToInt16(EnumList.EmployeeBillStatus.LineManagerApproved))
                                                                {
                                                                    if (subItem.EmployeeBillStatus == Convert.ToInt16(EnumList.EmployeeBillStatus.WaitingForLineManagerApproval))
                                                                    {
                                                                        List <Billdetails> billdetails = _dbTeleBillingContext.Billdetails.Where(x => x.EmployeeBillId == subItem.Id).ToList();
                                                                        var serviceBillDetials         = billdetails.GroupBy(x => x.ServiceTypeId);
                                                                        var finalServiceDetails        = serviceBillDetials.Where(x => x.Key == employeeBillServicePackage.ServiceTypeId);

                                                                        foreach (var billDetailsData in finalServiceDetails)
                                                                        {
                                                                            decimal personalDeduction = 0;
                                                                            decimal businessCharge    = 0;
                                                                            foreach (var subBillDetail in billDetailsData)
                                                                            {
                                                                                if (subBillDetail.CallIdentificationType == Convert.ToInt16(EnumList.AssignType.Business))
                                                                                {
                                                                                    businessCharge += subBillDetail.CallAmount != null?Convert.ToDecimal(subBillDetail.CallAmount) : 0;
                                                                                }
                                                                                else if (subBillDetail.CallIdentificationType == Convert.ToInt16(EnumList.AssignType.Employee))
                                                                                {
                                                                                    personalDeduction += subBillDetail.CallAmount != null?Convert.ToDecimal(subBillDetail.CallAmount) : 0;
                                                                                }
                                                                            }
                                                                            employeeBillServicePackage.PersonalIdentificationAmount = personalDeduction;
                                                                            employeeBillServicePackage.BusinessIdentificationAmount = businessCharge;
                                                                        }
                                                                    }

                                                                    if (employeeBillServicePackage.Package.PackageAmount < totalAmount)
                                                                    {
                                                                        decimal businessIdentificationAmount = employeeBillServicePackage.BusinessIdentificationAmount != null?Convert.ToDecimal(employeeBillServicePackage.BusinessIdentificationAmount) : 0;

                                                                        decimal amount = 0;
                                                                        if (employeeBillServicePackage.Package.PackageAmount < businessIdentificationAmount)
                                                                        {
                                                                            amount = businessIdentificationAmount;
                                                                        }
                                                                        else
                                                                        {
                                                                            amount = employeeBillServicePackage.Package.PackageAmount != null?Convert.ToDecimal(employeeBillServicePackage.Package.PackageAmount) : 0;
                                                                        }
                                                                        employeeBillServicePackage.DeductionAmount = totalAmount - amount;
                                                                        SendEmailNotificationToEmployee(employeeBillServicePackage, subItem);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            employeeBillServicePackage.DeductionAmount = 0;
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    employeeBillServicePackage.DeductionAmount = 0;
                                                }
                                                employeeBillServicePackage.UpdateDate = DateTime.Now;
                                            }

                                            _dbTeleBillingContext.UpdateRange(employeeBillServicePackages);
                                            _dbTeleBillingContext.SaveChanges();

                                            subItem.EmployeeBillStatus = Convert.ToInt16(EnumList.EmployeeBillStatus.AutoCloseBill);
                                            subItem.UpdatedDate        = DateTime.Now;
                                            subItem.BillClosedDate     = DateTime.Now;


                                            #region Notification FOR Bill Close
                                            notificationlogs.Add(GenerateNotificationObject(Convert.ToInt16(subItem.EmployeeId), 1, Convert.ToInt16(EnumList.NotificationType.BillClosed), subItem.Id));
                                            #endregion
                                        }

                                        if (notificationlogs.Any())
                                        {
                                            _dbTeleBillingContext.AddRange(notificationlogs);
                                            _dbTeleBillingContext.SaveChanges();
                                        }

                                        _dbTeleBillingContext.UpdateRange(employeeBillMasters);
                                        _dbTeleBillingContext.SaveChanges();

                                        Billmaster billMaster = _dbTeleBillingContext.Billmaster.FirstOrDefault(x => x.Id == employeeBillMasters[0].BillMasterId && !x.IsDelete);
                                        if (billMaster != null)
                                        {
                                            billMaster.BillStatusId = Convert.ToInt16(EnumList.BillStatus.BillClosed);
                                            billMaster.UpdatedDate  = DateTime.Now;

                                            _dbTeleBillingContext.Update(billMaster);
                                            _dbTeleBillingContext.SaveChanges();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (global::System.Exception ex)
                {
                    throw ex;
                }
            }
        }