public async Task <ResponseAC> AddInternetDevice(InternetDeviceAC internetDeviceAC, long userId, string loginUserName)
        {
            ResponseAC responeAC = new ResponseAC();

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

                await _dbTeleBilling_V01Context.AddAsync(mstInternetDeviceDetail);

                await _dbTeleBilling_V01Context.SaveChangesAsync();

                responeAC.Message    = _iStringConstant.InternetDeviceAddedSuccessfully;
                responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Success);
                await _iLogManagement.SaveAuditActionLog((int)EnumList.AuditLogActionType.AddInternetDevice, loginUserName, userId, "Internet device(" + mstInternetDeviceDetail.Name + ")", (int)EnumList.ActionTemplateTypes.Add, mstInternetDeviceDetail.Id);
            }
            else
            {
                responeAC.Message    = _iStringConstant.InternetDeviceAlreadyExists;
                responeAC.StatusCode = Convert.ToInt16(EnumList.ResponseType.Error);
            }
            return(responeAC);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AddInternetDevice(InternetDeviceAC internetDeviceAC)
        {
            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 _iInternetDeviceRepositoy.AddInternetDevice(internetDeviceAC, Convert.ToInt64(userId), fullname)));
        }
        public async Task <ResponseAC> EditInternetDevice(InternetDeviceAC internetDeviceAC, long userId)
        {
            ResponseAC responeAC = new ResponseAC();

            if (!await _dbTeleBilling_V01Context.MstInternetdevicedetail.AnyAsync(x => x.Id != internetDeviceAC.Id && x.Name.ToLower().Trim() == internetDeviceAC.Name.Trim().ToLower() && !x.IsDelete))
            {
                MstInternetdevicedetail mstInternetDeviceDetail = await _dbTeleBilling_V01Context.MstInternetdevicedetail.FirstOrDefaultAsync(x => x.Id == internetDeviceAC.Id && !x.IsDelete);

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

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

                #endregion

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

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