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 <IActionResult> AddHandset(HandsetDetailAC handsetDetailAC) { 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 _iHandsetRepository.AddHandset(handsetDetailAC, Convert.ToInt64(userId), fullname))); }
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); }