예제 #1
0
        public HttpResponseMessage updateAccountCategory(String id, Models.MstAccountCategory accountCategory)
        {
            try
            {
                var userId = (from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d.Id).SingleOrDefault();

                var accountCategories = from d in db.MstAccountCategories where d.Id == Convert.ToInt32(id) select d;
                if (accountCategories.Any())
                {
                    var updateAccountCategory = accountCategories.FirstOrDefault();
                    updateAccountCategory.AccountCategoryCode = accountCategory.AccountCategoryCode;
                    updateAccountCategory.AccountCategory     = accountCategory.AccountCategory;
                    updateAccountCategory.IsLocked            = accountCategory.IsLocked;
                    updateAccountCategory.UpdatedById         = userId;
                    updateAccountCategory.UpdatedDateTime     = DateTime.Now;

                    db.SubmitChanges();

                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
예제 #2
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);
            }
        }