public HttpResponseMessage AddAccountCashFlow(Entities.MstAccountCashFlow objAccountCashFlow) { 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) { Data.MstAccountCashFlow newAccountCashFlow = new Data.MstAccountCashFlow { AccountCashFlowCode = objAccountCashFlow.AccountCashFlowCode, AccountCashFlow = objAccountCashFlow.AccountCashFlow, IsLocked = true, CreatedById = currentUserId, CreatedDateTime = DateTime.Now, UpdatedById = currentUserId, UpdatedDateTime = DateTime.Now }; db.MstAccountCashFlows.InsertOnSubmit(newAccountCashFlow); db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } 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.")); } }
public HttpResponseMessage UpdateAccountCashFlow(Entities.MstAccountCashFlow objAccountCashFlow, String id) { 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().CanEdit) { var accountCashFlow = from d in db.MstAccountCashFlows where d.Id == Convert.ToUInt32(id) select d; if (accountCashFlow.Any()) { var updateAccountCashFlow = accountCashFlow.FirstOrDefault(); updateAccountCashFlow.AccountCashFlowCode = objAccountCashFlow.AccountCashFlowCode; updateAccountCashFlow.AccountCashFlow = objAccountCashFlow.AccountCashFlow; updateAccountCashFlow.IsLocked = true; updateAccountCashFlow.UpdatedById = currentUserId; updateAccountCashFlow.UpdatedDateTime = DateTime.Now; db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "This account cash flow detail is no longer available.")); } } 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.")); } }