public string SaveIpFeedbackForm(IpFeedback ipFeedback) { int newFormNumber = 1; IQueryable <SerialNumbertrackerRA> queryableSerialNumberTrackerRAData = this.unitOfWork.DbContext.SerialNumbertrackerRA .Where(x => x.UserCode == ipFeedback.CreatedBy && x.FormType == "IPF"); if (queryableSerialNumberTrackerRAData.Any()) { newFormNumber = queryableSerialNumberTrackerRAData.Max(y => y.SerialValue) + 1;; } string padding = "000"; string serialNumberComponent = padding.Remove(padding.Length - newFormNumber.ToString().Length) + (newFormNumber).ToString(); ipFeedback.IpFeedbackNumber = "IPF-" + ipFeedback.CreatedBy + "-" + serialNumberComponent; /*Form entry*/ IpFeedback IpFeedbackObj = this.unitOfWork.DbContext.ipFeedback.Add(ipFeedback); /*Serial Number updation*/ SerialNumbertrackerRA serialNumbertrackerRAObj = new SerialNumbertrackerRA { FormType = "IPF", UserCode = ipFeedback.CreatedBy, SerialValue = newFormNumber, GeneratedDate = DateTime.UtcNow.AddHours(5.5) }; serialNumbertrackerRAObj = this.unitOfWork.DbContext.SerialNumbertrackerRA.Add(serialNumbertrackerRAObj); this.unitOfWork.DbContext.SaveChanges(); return(IpFeedbackObj.IpFeedbackNumber); }
public IActionResult SaveIpFeedbackForm([FromBody] IpFeedback ipFeedback) { ipFeedback.CreatedDateTime = DateTime.UtcNow.AddHours(5.5); var updatedForm = this._svpBusinessAccess.SaveIpFeedbackForm(ipFeedback); return(Ok(updatedForm)); }
public string SaveIpFeedbackForm(IpFeedback ipFeedback) { string ipFeedbackNumber = this.svpDataAccess.SaveIpFeedbackForm(ipFeedback); return(ipFeedbackNumber); }