public Int32 insertAccountCategory(Models.MstAccountCategory accountCategory) { try { var userId = (from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d.Id).SingleOrDefault(); Data.MstAccountCategory newAccountCategory = new Data.MstAccountCategory(); newAccountCategory.AccountCategoryCode = accountCategory.AccountCategoryCode; newAccountCategory.AccountCategory = accountCategory.AccountCategory; newAccountCategory.IsLocked = accountCategory.IsLocked; newAccountCategory.CreatedById = userId; newAccountCategory.CreatedDateTime = DateTime.Now; newAccountCategory.UpdatedById = userId; newAccountCategory.UpdatedDateTime = DateTime.Now; db.MstAccountCategories.InsertOnSubmit(newAccountCategory); db.SubmitChanges(); return newAccountCategory.Id; } catch { return 0; } }
public Int32 insertAccountCategory(Models.MstAccountCategory accountCategory) { try { var userId = (from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d.Id).SingleOrDefault(); Data.MstAccountCategory newAccountCategory = new Data.MstAccountCategory(); newAccountCategory.AccountCategoryCode = accountCategory.AccountCategoryCode; newAccountCategory.AccountCategory = accountCategory.AccountCategory; newAccountCategory.IsLocked = accountCategory.IsLocked; newAccountCategory.CreatedById = userId; newAccountCategory.CreatedDateTime = DateTime.Now; newAccountCategory.UpdatedById = userId; newAccountCategory.UpdatedDateTime = DateTime.Now; db.MstAccountCategories.InsertOnSubmit(newAccountCategory); db.SubmitChanges(); return(newAccountCategory.Id); } catch { return(0); } }
public HttpResponseMessage AddAccountCategory(Entities.MstAccountCategory objAccountCategory) { 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.MstAccountCategory newAccountCategory = new Data.MstAccountCategory { AccountCategoryCode = objAccountCategory.AccountCategoryCode, AccountCategory = objAccountCategory.AccountCategory, IsLocked = true, CreatedById = currentUserId, CreatedDateTime = DateTime.Now, UpdatedById = currentUserId, UpdatedDateTime = DateTime.Now }; db.MstAccountCategories.InsertOnSubmit(newAccountCategory); 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.")); } }