public void LogglTransaction(oGlAccount obj, bool isPosted, ErrorLog errLog = null) { try { log.TransactionNo = obj.AccntCode; log.Origin = string.Format("{0}-{1}", HttpContext.Current.Request.UserHostAddress, HttpContext.Current.Request.UserHostName); log.Type = TransactionLog.SBOType.GL; log.LogDate = DateTime.Now; log.IsPosted = isPosted; log.TransactionDataID = log.RawData.ID; log.RawData.PostedOn = obj.CreateDate; log.RawData.RawData = JsonConvert.SerializeObject(obj); repo.AddOrUpdate(log); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <IHttpActionResult> AddLedgerAccount(oGlAccount glAccount) { try { if (!GlobalInstance.Instance.IsConnected) { GlobalInstance.Instance.InitializeSboComObject(); } var gl = await repo.GetByAccountCode(glAccount.AccntCode); if (gl != null) { errMsg = string.Format("Ledger account {0}-{1} already exist.", glAccount.AccntCode, glAccount.AccntName); var resp = new HttpResponseMessage(HttpStatusCode.Conflict); resp.Content = new StringContent(errMsg); resp.ReasonPhrase = "Object already exist."; throw new HttpResponseException(resp); } if (repo.Add(glAccount) < 0) { errMsg = GlobalInstance.Instance.SBOErrorMessage; var resp = new HttpResponseMessage(HttpStatusCode.Conflict); resp.Content = new StringContent(errMsg); resp.ReasonPhrase = "SBO Error"; throw new HttpResponseException(resp); } return(Ok(string.Format("Ledger account {0}-{1} already exist.", glAccount.AccntCode, glAccount.AccntName))); } catch (HttpResponseException ex) { throw new HttpResponseException(HttpStatusCode.BadRequest); } }
public void LogGlTransaction(oGlAccount obj, bool isPosted, string action, string origin, ErrorLog errLog = null) { try { log.TransactionNo = obj.AccntCode; log.Origin = origin; log.Type = TransactionLog.SBOType.GL; log.LogDate = DateTime.Now; log.IsPosted = isPosted; TransactionData rawData = new TransactionData(); rawData.PostedOn = obj.CreateDate; rawData.RawData = JsonConvert.SerializeObject(obj); log.RawData = rawData; log.Action = action; log.CreatedBy = obj.CreatedBy; log.CreatedOn = obj.CreateDate; repo.AddOrUpdate(log); } catch (Exception ex) { throw new Exception(ex.Message); } }