public Int32 insertAccount(Models.MstAccount account) { try { var userId = (from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d.Id).SingleOrDefault(); Data.MstAccount newAccount = new Data.MstAccount(); newAccount.AccountCode = account.AccountCode; newAccount.Account = account.Account; newAccount.AccountTypeId = account.AccountTypeId; newAccount.AccountCashFlowId = account.AccountCashFlowId; newAccount.IsLocked = account.IsLocked; newAccount.CreatedById = userId; newAccount.CreatedDateTime = DateTime.Now; newAccount.UpdatedById = userId; newAccount.UpdatedDateTime = DateTime.Now; ; db.MstAccounts.InsertOnSubmit(newAccount); db.SubmitChanges(); return newAccount.Id; } catch { return 0; } }
public Int32 insertAccount(Models.MstAccount account) { try { var userId = (from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d.Id).SingleOrDefault(); Data.MstAccount newAccount = new Data.MstAccount(); newAccount.AccountCode = account.AccountCode; newAccount.Account = account.Account; newAccount.AccountTypeId = account.AccountTypeId; newAccount.AccountCashFlowId = account.AccountCashFlowId; newAccount.IsLocked = account.IsLocked; newAccount.CreatedById = userId; newAccount.CreatedDateTime = DateTime.Now; newAccount.UpdatedById = userId; newAccount.UpdatedDateTime = DateTime.Now;; db.MstAccounts.InsertOnSubmit(newAccount); db.SubmitChanges(); return(newAccount.Id); } catch { return(0); } }
public Int32 postAccount() { try { Data.MstAccount newAccount = new Data.MstAccount(); newAccount.Code = "n/a"; newAccount.Account = "n/a"; newAccount.IsLocked = false; newAccount.AccountType = "n/a"; db.MstAccounts.InsertOnSubmit(newAccount); db.SubmitChanges(); return(newAccount.Id); } catch (Exception e) { return(0); } }
public int Post(Models.MstAccount account) { try { var isLocked = true; Data.MstAccount newAccount = new Data.MstAccount(); newAccount.Account = account.Account; newAccount.IsLocked = isLocked; newAccount.Code = account.Code; newAccount.AccountType = account.AccountType; db.MstAccounts.InsertOnSubmit(newAccount); db.SubmitChanges(); return newAccount.Id; } catch { return 0; } }
public HttpResponseMessage AddAccount(Entities.MstAccount objAccount) { try { var currentUser = from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d; if (currentUser.Any()) { var currentUserId = currentUser.FirstOrDefault().Id; var userForms = from d in db.MstUserForms where d.UserId == currentUserId && d.SysForm.FormName.Equals("ChartOfAccounts") select d; if (userForms.Any()) { if (userForms.FirstOrDefault().CanAdd) { var accountTypes = from d in db.MstAccountTypes where d.IsLocked == true select d; if (accountTypes.Any()) { var accountCashFlows = from d in db.MstAccountCashFlows where d.IsLocked == true select d; if (accountCashFlows.Any()) { Data.MstAccount newAccount = new Data.MstAccount { AccountCode = objAccount.AccountCode, Account = objAccount.Account, AccountTypeId = objAccount.AccountTypeId, AccountCashFlowId = objAccount.AccountCashFlowId, IsLocked = objAccount.IsLocked, CreatedById = currentUserId, CreatedDateTime = DateTime.Now, UpdatedById = currentUserId, UpdatedDateTime = DateTime.Now }; db.MstAccounts.InsertOnSubmit(newAccount); db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "No account cash flow found. Please setup more account cash flows for all chart of account tables.")); } } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "No account type found. Please setup more account types for all chart of account tables.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Sorry. You have no rights to add new account in this chart of account page.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Sorry. You have no access in this chart of account page.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Theres no current user logged in.")); } } catch (Exception e) { Debug.WriteLine(e); return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Something's went wrong from the server.")); } }
public HttpResponseMessage AddAccount(Entities.MstAccount objAccount) { try { var currentUser = from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d; if (currentUser.Any()) { var currentUserId = currentUser.FirstOrDefault().Id; var userForms = from d in db.MstUserForms where d.UserId == currentUserId && d.SysForm.FormName.Equals("ChartOfAccounts") select d; if (userForms.Any()) { if (userForms.FirstOrDefault().CanAdd) { var accountTypes = from d in db.MstAccountTypes where d.IsLocked == true && d.Id == objAccount.AccountTypeId select d; if (accountTypes.Any()) { var accountCashFlows = from d in db.MstAccountCashFlows where d.IsLocked == true && d.Id == objAccount.AccountCashFlowId select d; if (accountCashFlows.Any()) { Data.MstAccount newAccount = new Data.MstAccount { AccountCode = objAccount.AccountCode, Account = objAccount.Account, AccountTypeId = objAccount.AccountTypeId, AccountCashFlowId = objAccount.AccountCashFlowId, IsLocked = true, CreatedById = currentUserId, CreatedDateTime = DateTime.Now, UpdatedById = currentUserId, UpdatedDateTime = DateTime.Now }; db.MstAccounts.InsertOnSubmit(newAccount); db.SubmitChanges(); String newObject = at.GetObjectString(newAccount); at.InsertAuditTrail(currentUser.FirstOrDefault().Id, GetType().Name, MethodBase.GetCurrentMethod().Name, "NA", newObject); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "Account cash flow not found.")); } } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "Account type not found.")); } } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "No rights.")); } } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "No rights.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Theres no current user logged in.")); } } catch (Exception e) { Debug.WriteLine(e); return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Something's went wrong from the server.")); } }