public async Task <ResponseAC> AddHandset(HandsetDetailAC handsetDetailAC, long userId, string loginUserName)
        {
            ResponseAC responeAC = new ResponseAC();

            if (!await _dbTeleBilling_V01Context.MstHandsetdetail.AnyAsync(x => x.Name.ToLower().Trim() == handsetDetailAC.Name.ToLower().Trim() && !x.IsDelete))
            {
                MstHandsetdetail mstHandsetDetail = new MstHandsetdetail();
                mstHandsetDetail.Name          = handsetDetailAC.Name.Trim();
                mstHandsetDetail.CreatedBy     = userId;
                mstHandsetDetail.CreatedDate   = DateTime.Now;
                mstHandsetDetail.TransactionId = _iLogManagement.GenerateTeleBillingTransctionID();

                await _dbTeleBilling_V01Context.AddAsync(mstHandsetDetail);

                await _dbTeleBilling_V01Context.SaveChangesAsync();

                responeAC.Message    = _iStringConstant.HandsetAddedSuccessfully;
                responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Success);
                await _iLogManagement.SaveAuditActionLog((int)EnumList.AuditLogActionType.AddHandset, loginUserName, userId, "Handset(" + mstHandsetDetail.Name + ")", (int)EnumList.ActionTemplateTypes.Add, mstHandsetDetail.Id);
            }
            else
            {
                responeAC.Message    = _iStringConstant.HandsetAlreadyExists;
                responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Error);
            }
            return(responeAC);
        }
        public async Task <ResponseAC> EditHandset(HandsetDetailAC handsetDetailAC, long userId)
        {
            ResponseAC responeAC = new ResponseAC();

            if (!await _dbTeleBilling_V01Context.MstHandsetdetail.AnyAsync(x => x.Id != handsetDetailAC.Id && x.Name.ToLower().Trim() == handsetDetailAC.Name.Trim().ToLower() && !x.IsDelete))
            {
                MstHandsetdetail mstHandsetDetail = await _dbTeleBilling_V01Context.MstHandsetdetail.FirstOrDefaultAsync(x => x.Id == handsetDetailAC.Id && !x.IsDelete);

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

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

                #endregion

                mstHandsetDetail.Name        = handsetDetailAC.Name.Trim();
                mstHandsetDetail.UpdatedBy   = userId;
                mstHandsetDetail.UpdatedDate = DateTime.Now;
                _dbTeleBilling_V01Context.Update(mstHandsetDetail);
                await _dbTeleBilling_V01Context.SaveChangesAsync();

                responeAC.Message    = _iStringConstant.HandsetUpdateSuccessfully;
                responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Success);
            }
            else
            {
                responeAC.Message    = _iStringConstant.HandsetAlreadyExists;
                responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Error);
            }
            return(responeAC);
        }
        public async Task <bool> DeleteHandset(long id, long userId, string loginUserName)
        {
            List <Providerpackage> providerpackages = await _dbTeleBilling_V01Context.Providerpackage.Where(x => x.HandsetDetailIds.Contains(id.ToString()) && x.IsActive && !x.IsDelete).ToListAsync();

            if (!providerpackages.Any())
            {
                MstHandsetdetail mstHandsetDetail = await _dbTeleBilling_V01Context.MstHandsetdetail.FirstOrDefaultAsync(x => x.Id == id);

                mstHandsetDetail.IsDelete    = true;
                mstHandsetDetail.UpdatedBy   = userId;
                mstHandsetDetail.UpdatedDate = DateTime.Now;
                _dbTeleBilling_V01Context.Update(mstHandsetDetail);
                await _dbTeleBilling_V01Context.SaveChangesAsync();

                await _iLogManagement.SaveAuditActionLog((int)EnumList.AuditLogActionType.DeleteHandset, loginUserName, userId, "Handset(" + mstHandsetDetail.Name + ")", (int)EnumList.ActionTemplateTypes.Edit, mstHandsetDetail.Id);

                return(true);
            }
            return(false);
        }
Beispiel #4
0
        public async Task <PackageDetailAC> GetPackageById(long id)
        {
            Providerpackage providerPackage = await _dbTeleBilling_V01Context.Providerpackage.FirstOrDefaultAsync(x => x.Id == id);

            PackageDetailAC packageDetailAC = _mapper.Map <PackageDetailAC>(providerPackage);

            if (!string.IsNullOrEmpty(packageDetailAC.HandsetDetailIds))
            {
                packageDetailAC.HandsetList = new List <DrpResponseAC>();
                List <string> lstHandsetIds = packageDetailAC.HandsetDetailIds.Split(',').ToList();
                foreach (string handsetId in lstHandsetIds)
                {
                    DrpResponseAC    drpResponseAC = new DrpResponseAC();
                    long             newHandsetId  = Convert.ToInt64(handsetId);
                    MstHandsetdetail handsetDetail = await _dbTeleBilling_V01Context.MstHandsetdetail.FirstOrDefaultAsync(x => x.Id == newHandsetId && !x.IsDelete);

                    drpResponseAC.Id   = handsetDetail.Id;
                    drpResponseAC.Name = handsetDetail.Name;
                    packageDetailAC.HandsetList.Add(drpResponseAC);
                }
            }
            return(packageDetailAC);
        }
        public async Task <HandsetDetailAC> GetHandsetById(long id)
        {
            MstHandsetdetail handsetDetail = await _dbTeleBilling_V01Context.MstHandsetdetail.FirstOrDefaultAsync(x => !x.IsDelete && x.Id == id);

            return(_mapper.Map <HandsetDetailAC>(handsetDetail));
        }