protected void btnSave_OnServerClick(object sender, EventArgs e)
        {
            string categoryName = Request.Form["categoryname"];
            string icon         = Request.Form["icon"];

            _categoryDal.Add(new Category
            {
                CategoryName = categoryName,
                Picture      = _imagePath + categoryImage.Value,
                Icon         = icon
            });

            End("Category Added!");
        }
Ejemplo n.º 2
0
 public string Add(Category entity)
 {
     try
     {
         if (!IsCategoryComplete(entity))
         {
             return("Kategori Bilgileri Hatalı");
         }
         return(categoryDal.Add(entity));
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Ejemplo n.º 3
0
 public Category Add(Category category)
 {
     return(_mapper.Map <Category>(_categoryDal.Add(category)));
 }
Ejemplo n.º 4
0
        public Category Add(Category item)
        {
            CategoryDal categoryDal = new CategoryDal();

            return(categoryDal.Add(item));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 添加或修改分类信息
        /// <br/>
        /// 清除分类缓存
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public ReturnValue AddOrEdit(Category entity)
        {
            ReturnValue retValue = new ReturnValue();

            if (string.IsNullOrEmpty(entity.Name))
            {
                retValue.IsExists = false;
                retValue.Message = "分类名称";
                return retValue;
            }
            if (string.IsNullOrEmpty(entity.Title))
            {
                retValue.IsExists = false;
                retValue.Message = "分类显示名称";
                return retValue;
            }

            using (CategoryDal dal = new CategoryDal())
            {
                Category old = dal.Get(entity.CategoryID);
                if (old == null)//添加
                {
                    old = dal.GetByName(entity.Name);
                    if (old != null)
                    {
                        retValue.IsExists = false;
                        retValue.Message = "分类已存在";
                        return retValue;
                    }
                    if (dal.Add(entity))
                    {
                        retValue.IsExists = true;
                        retValue.Message = "分类添加成功";
                    }
                    else
                    {
                        retValue.IsExists = false;
                        retValue.Message = "分类添加失败";
                    }
                }
                else
                {
                    if (entity.Name != old.Name)
                    {
                        old = dal.GetByName(entity.Name);
                        if (old != null)
                        {
                            retValue.IsExists = false;
                            retValue.Message = "分类已存在";
                            return retValue;
                        }
                    }
                    if (dal.Modify(entity))
                    {
                        retValue.IsExists = true;
                        retValue.Message = "分类修改成功";
                    }
                    else
                    {
                        retValue.IsExists = false;
                        retValue.Message = "分类修改失败";
                    }
                }
            }
            if (retValue.IsExists)
            {
                ClearCache();
            }
            return retValue;
        }