Пример #1
0
 /// <summary>
 /// Cập nhật isdeleted = true cho CatType
 /// </summary>
 /// <param name="cat"></param>
 /// <param name="userName"></param>
 /// <returns></returns>
 public object DeleteCateType(MNG_CatType cat)
 {
     try
     {
         MNG_CatType _cat = dbContext.MNG_CatType.Where(x => x.CatTypeCode == cat.CatTypeCode && !x.IsDeleted).FirstOrDefault();
         if (_cat != null)
         {
             _cat.IsDeleted = true;
             dbContext.SaveChanges();
             return(MP_AjaxError.OK);
         }
         else
         {
             return(MP_AjaxError.NotFound);
         }
     }
     catch (System.Exception ex)
     {
         return(ex.Message);
     }
 }
Пример #2
0
        /// <summary>
        /// Cập nhật tên danh mục
        /// </summary>
        /// <param name="cat"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public object UpdateCateTypeName(MNG_CatType cat, string userName)
        {
            try
            {
                MNG_CatType catType = dbContext.MNG_CatType.Where(x => x.CatTypeCode == cat.CatTypeCode && !x.IsDeleted).FirstOrDefault();
                if (catType == null)
                {
                    return(MP_AjaxError.NotFound);
                }
                if (dbContext.MNG_CatType.Any(x => x.CatTypeName == cat.CatTypeName && x.CatTypeCode != cat.CatTypeCode))
                {
                    return(MP_AjaxError.Exits);
                }

                catType.CatTypeName = cat.CatTypeName;
                dbContext.SaveChanges();
                return(MP_AjaxError.OK);
            }
            catch (System.Exception ex)
            {
                return(ex.Message);
            }
        }
Пример #3
0
        /// <summary>
        /// Thêm mới CatType
        /// </summary>
        /// <param name="cat"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public object AddNewCatType(MNG_CatType cat, string userName)
        {
            try
            {
                #region HANDLER
                string[] value  = CRMHelper.RemoveUnicode(cat.CatTypeName).Split(' ');
                string   result = string.Empty;
                for (int i = 0; i < value.Count(); i++)
                {
                    result += value[i].Substring(0, 1);
                }
                if (result.Length > 5)
                {
                    result = result.Substring(0, 5);
                }

                if (!dbContext.MNG_Category.Any(x => x.CatTypeCode == result))
                {
                    cat.IsDeleted   = false;
                    cat.CatTypeCode = result;
                    dbContext.MNG_CatType.Add(cat);
                    dbContext.SaveChanges();
                }
                else
                {
                    return(MP_AjaxError.Exits);
                }
                return(MP_AjaxError.OK);

                #endregion
            }
            catch (System.Exception ex)
            {
                return(ex.Message);
            }
        }
Пример #4
0
 public HttpResponseMessage DeleteCateType(MNG_CatType cat)
 {
     return(Request.CreateResponse(HttpStatusCode.OK, new { status = _categoryServices.DeleteCateType(cat) }));
 }
Пример #5
0
 public HttpResponseMessage AddNewCatType(MNG_CatType cat)
 {
     return(Request.CreateResponse(HttpStatusCode.OK,
                                   new { status = _categoryServices.AddNewCatType(cat, this.RequestContext.Principal.Identity.Name) }));
 }