Exemplo n.º 1
0
 public bool InsertCategoryValue(CategoryValueModel model)
 {
     try
     {
         if (model == null)
         {
             return(false);
         }
         using (var db = new PORTALEntities())
         {
             var item = new SysCategoryValue()
             {
                 ID         = Guid.NewGuid(),
                 Name       = model.Name,
                 Dictionary = model.Dictionary,
                 Sequence   = model.Sequence,
                 Actived    = model.Actived,
                 Category   = model.Category,
                 ParentID   = model.ParentID,
                 Remark     = model.RemarkValue,
                 CreateDate = model.CreateDate,
                 CreateUid  = model.CreateUID,
                 SubCode    = model.SubCode
             };
             db.SysCategoryValues.Add(item);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         LogHelper.Error("CategoryRepository InsertCategoryValue: " + ex.Message + " Inner exception: " + ex.InnerException.Message);
         return(false);
     }
 }
Exemplo n.º 2
0
 public bool DeleteCategoryValue(CategoryValueModel model)
 {
     try
     {
         if (model == null)
         {
             return(false);
         }
         using (var db = new PORTALEntities())
         {
             var item = (from c in db.SysCategoryValues
                         where c.ID == model.ID
                         select c).FirstOrDefault();
             if (item == null)
             {
                 return(false);
             }
             item.IsDelete   = true;
             item.DeleteDate = model.DeleteDate;
             item.DeleteUid  = model.DeleteUID;
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         LogHelper.Error("CategoryRepository DeleteCategoryValue: " + ex.Message + " Inner exception: " + ex.InnerException.Message);
         return(false);
     }
 }
Exemplo n.º 3
0
        public JsonResult UpdateCategoryValue(CategoryValueModel model)
        {
            model.ModifyDate = DateTime.Now;
            model.ModifyUID  = User.GetClaimValue(ClaimTypes.Sid);
            var result = res.UpdateCategoryValue(model);

            return(Json(result ? new { result = "OK" } : new { result = "Error" }));
        }
Exemplo n.º 4
0
        public JsonResult InsertCategoryValue(CategoryValueModel model)
        {
            model.CreateDate = DateTime.Now;
            model.CreateUID  = User.GetClaimValue(ClaimTypes.Sid);
            var result = res.InsertCategoryValue(model);

            return(Json(result ? new { result = "OK" } : new { result = "Error" }));
        }
Exemplo n.º 5
0
 public string CheckExistCateValue(CategoryValueModel model)
 {
     if (model == null)
     {
         return("Model is null");
     }
     return(res.CheckExistCateValue(model.Category.ToString(), model.Name) ? "Name is exists!" : "OK");
 }
Exemplo n.º 6
0
        public ActionResult ShowModalCreateCategoryValue(string id)
        {
            var model = new CategoryValueModel()
            {
                Category = new Guid(id)
            };

            return(PartialView("CreateCategoryValue", model));
        }
Exemplo n.º 7
0
        public JsonResult DeleteCategoryValue(string id)
        {
            var model = new CategoryValueModel
            {
                ID         = new Guid(id),
                DeleteDate = DateTime.Now,
                DeleteUID  = User.GetClaimValue(ClaimTypes.Sid)
            };
            var result = res.DeleteCategoryValue(model);

            return(Json(result ? new { result = "OK" } : new { result = "Error" }));
        }
Exemplo n.º 8
0
        public static List <CategoryValueModel> GetCategoryValue(string catId)
        {
            List <CategoryValueModel> result = new List <CategoryValueModel>();
            CategoryAccess            access = new CategoryAccess();
            DataTable dtResult = access.SP_CATEGORY_VALUE_QRY(catId);

            foreach (DataRow dtr in dtResult.Rows)
            {
                CategoryValueModel item = new CategoryValueModel
                {
                    CAT_VALUE_ID   = dtr["CAT_VALUE_ID"].ToString(),
                    CAT_CODE       = dtr["CAT_CODE"].ToString(),
                    CAT_VALUE      = dtr["CAT_VALUE"].ToString(),
                    CATEGORY_ID    = dtr["CATEGORY_ID"].ToString(),
                    SEQ            = dtr["SEQ"].ToString(),
                    DICTIONARY_ID  = dtr["DICTIONARY_ID"].ToString(),
                    MOTHER_ID      = dtr["MOTHER_ID"].ToString(),
                    MOTHER_NAME    = dtr["MOTHER_NAME"].ToString(),
                    IS_ACTIVE      = dtr["IS_ACTIVE"].ToString() == "1",
                    ORDERINDEX     = dtr["ORDERINDEX"].ToString(),
                    ISEDIT         = dtr["ISEDIT"].ToString() == "1",
                    CREATE_UID     = dtr["CREATE_UID"].ToString(),
                    UPDATE_UID     = dtr["UPDATE_UID"].ToString(),
                    SUBCODE        = dtr["SUBCODE"].ToString(),
                    IS_ACTIVE2     = dtr["IS_ACTIVE2"].ToString(),
                    DICTIONARY_ID2 = dtr["DICTIONARY_ID2"].ToString(),
                };
                if (!string.IsNullOrEmpty(dtr["CREATE_DT"].ToString()))
                {
                    item.CREATE_DT = DateTime.Parse(dtr["CREATE_DT"].ToString());
                }
                if (!string.IsNullOrEmpty(dtr["UPDATE_DT"].ToString()))
                {
                    item.UPDATE_DT = DateTime.Parse(dtr["UPDATE_DT"].ToString());
                }

                result.Add(item);
            }

            return(result);
        }
Exemplo n.º 9
0
 public bool UpdateCategoryValue(CategoryValueModel model)
 {
     try
     {
         if (model == null)
         {
             return(false);
         }
         using (var db = new PORTALEntities())
         {
             var item = (from c in db.SysCategoryValues
                         where c.ID == model.ID
                         select c).FirstOrDefault();
             if (item == null)
             {
                 return(false);
             }
             item.Name       = model.Name;
             item.Dictionary = model.Dictionary;
             item.Sequence   = model.Sequence;
             item.Actived    = model.Actived;
             item.Category   = model.Category;
             item.ParentID   = model.ParentID;
             item.Remark     = model.RemarkValue;
             item.UpdateDate = model.ModifyDate;
             item.UpdateUid  = model.ModifyUID;
             item.SubCode    = model.SubCode;
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         LogHelper.Error("CategoryRepository UpdateCategoryValue: " + ex.Message + " Inner exception: " + ex.InnerException.Message);
         return(false);
     }
 }