public HttpResponseMessage updateAccountCashFlow(String id, Models.MstAccountCashFlow accountCashFlow) { try { var userId = (from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d.Id).SingleOrDefault(); var accountCashFlows = from d in db.MstAccountCashFlows where d.Id == Convert.ToInt32(id) select d; if (accountCashFlows.Any()) { var updateAccountCashFlow = accountCashFlows.FirstOrDefault(); updateAccountCashFlow.AccountCashFlowCode = accountCashFlow.AccountCashFlowCode; updateAccountCashFlow.AccountCashFlow = accountCashFlow.AccountCashFlow; updateAccountCashFlow.IsLocked = accountCashFlow.IsLocked; updateAccountCashFlow.UpdatedById = userId; updateAccountCashFlow.UpdatedDateTime = DateTime.Now; db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.NotFound)); } } catch { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public Int32 insertAccountCashFlow(Models.MstAccountCashFlow accountCashFlow) { try { var userId = (from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d.Id).SingleOrDefault(); Data.MstAccountCashFlow newAccountCashFlow = new Data.MstAccountCashFlow(); newAccountCashFlow.AccountCashFlowCode = accountCashFlow.AccountCashFlowCode; newAccountCashFlow.AccountCashFlow = accountCashFlow.AccountCashFlow; newAccountCashFlow.IsLocked = accountCashFlow.IsLocked; newAccountCashFlow.CreatedById = userId; newAccountCashFlow.CreatedDateTime = DateTime.Now; newAccountCashFlow.UpdatedById = userId; newAccountCashFlow.UpdatedDateTime = DateTime.Now; db.MstAccountCashFlows.InsertOnSubmit(newAccountCashFlow); db.SubmitChanges(); return(newAccountCashFlow.Id); } catch { return(0); } }