Example #1
0
        public async Task <ResponseAC> AddDelegate(BillDelegatesAC billDelegatesAC, long userId, string loginUserName)
        {
            ResponseAC responeAC = new ResponseAC();

            if (await _dbTeleBilling_V01Context.Billdelegate.FirstOrDefaultAsync(x => x.EmployeeId == billDelegatesAC.Employee.UserId && x.DelegateEmployeeId == billDelegatesAC.DelegateEmployee.UserId && !x.IsDelete) == null)
            {
                TeleBillingUtility.Models.Billdelegate delegateDetail = new TeleBillingUtility.Models.Billdelegate();

                delegateDetail.EmployeeId              = billDelegatesAC.Employee.UserId;
                delegateDetail.DelegateEmployeeId      = billDelegatesAC.DelegateEmployee.UserId;
                delegateDetail.AllowBillApproval       = billDelegatesAC.AllowBillApproval;
                delegateDetail.AllowBillIdentification = billDelegatesAC.AllowBillIdentification;
                delegateDetail.CreatedBy     = userId;
                delegateDetail.CreatedDate   = DateTime.Now;
                delegateDetail.TransactionId = _iLogManagement.GenerateTeleBillingTransctionID();

                await _dbTeleBilling_V01Context.AddAsync(delegateDetail);

                await _dbTeleBilling_V01Context.SaveChangesAsync();

                responeAC.Message    = _iStringConstant.DelegateAddedSuccessfully;
                responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Success);

                await _iLogManagement.SaveAuditActionLog((int)EnumList.AuditLogActionType.AddDelegate, loginUserName, userId, "Delegate user", (int)EnumList.ActionTemplateTypes.Add, delegateDetail.Id);
            }
            else
            {
                responeAC.Message    = _iStringConstant.DelegateAlreadyExists;
                responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Error);
            }
            return(responeAC);
        }
Example #2
0
        public async Task <BillDelegatesAC> GetDelegateById(long id)
        {
            TeleBillingUtility.Models.Billdelegate delegateDetail = await _dbTeleBilling_V01Context.Billdelegate.Include(x => x.Employee).Include(x => x.DelegateEmployee).FirstOrDefaultAsync(x => !x.IsDelete && x.Id == id);

            BillDelegatesAC billDelegatesAC = new BillDelegatesAC();

            billDelegatesAC.Id                      = id;
            billDelegatesAC.Employee                = new EmployeeAC();
            billDelegatesAC.Employee                = _mapper.Map <EmployeeAC>(delegateDetail.Employee);
            billDelegatesAC.DelegateEmployee        = new EmployeeAC();
            billDelegatesAC.DelegateEmployee        = _mapper.Map <EmployeeAC>(delegateDetail.DelegateEmployee);
            billDelegatesAC.AllowBillApproval       = delegateDetail.AllowBillApproval;
            billDelegatesAC.AllowBillIdentification = delegateDetail.AllowBillIdentification;
            return(billDelegatesAC);
        }
Example #3
0
        public async Task <ResponseAC> EditDelegate(BillDelegatesAC billDelegatesAC, long userId, string loginUserName)
        {
            ResponseAC responeAC = new ResponseAC();

            if (await _dbTeleBilling_V01Context.Billdelegate.FirstOrDefaultAsync(x => x.Id != billDelegatesAC.Id && x.EmployeeId == billDelegatesAC.Employee.UserId && x.DelegateEmployeeId == billDelegatesAC.DelegateEmployee.UserId && !x.IsDelete) == null)
            {
                TeleBillingUtility.Models.Billdelegate delegateDetail = await _dbTeleBilling_V01Context.Billdelegate.FirstOrDefaultAsync(x => x.Id == billDelegatesAC.Id && !x.IsDelete);

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

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

                #endregion

                delegateDetail.EmployeeId              = billDelegatesAC.Employee.UserId;
                delegateDetail.DelegateEmployeeId      = billDelegatesAC.DelegateEmployee.UserId;
                delegateDetail.AllowBillApproval       = billDelegatesAC.AllowBillApproval;
                delegateDetail.AllowBillIdentification = billDelegatesAC.AllowBillIdentification;
                delegateDetail.UpdatedBy   = userId;
                delegateDetail.UpdatedDate = DateTime.Now;

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

                responeAC.Message    = _iStringConstant.DelegateUpdateSuccessfully;
                responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Success);
                await _iLogManagement.SaveAuditActionLog((int)EnumList.AuditLogActionType.EditDelegate, loginUserName, userId, "Delegate user", (int)EnumList.ActionTemplateTypes.Edit, delegateDetail.Id);
            }
            else
            {
                responeAC.Message    = _iStringConstant.DelegateAlreadyExists;
                responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Error);
            }
            return(responeAC);
        }