예제 #1
0
        public JsonResult BathcProductCreate(int?[] ids, ProductDiscountDto dto)
        {
            OperationResult resul = new OperationResult(OperationResultType.Error);

            #region 添加前校验

            if (!string.IsNullOrEmpty(dto.DiscountName))
            {
                bool exis = _productDiscountContract.ProductDiscounts.Any(
                    c => c.DiscountName == dto.DiscountName && !c.IsDeleted && c.IsEnabled);
                if (exis)
                {
                    resul.Message = "已存在同名的折扣方案";
                    return(Json(resul));
                }
            }
            #endregion
            string _validSessionKey  = "1102_validsessionkey_09";
            string _invaliSessionKey = "1102_invalidsessionkey_03";

            if (ids.Any(c => c != null))
            {
                if (dto.DiscountType == 1)
                {
                    dto.BigNumbers = string.Join(",", ids);
                }
                resul = _productDiscountContract.Insert(dto);
            }
            else
            {
                var discountvalids = SessionAccess.Get(_validSessionKey) as List <DiscountValidSession>;
                if (discountvalids != null)
                {
                    resul = _productDiscountContract.Insert(dto);
                }
                else
                {
                    resul = new OperationResult(OperationResultType.ValidError);
                }
            }
            if (resul.ResultType == OperationResultType.Success)
            {
                SessionAccess.Remove(_validSessionKey);
                SessionAccess.Remove(_invaliSessionKey);
            }
            return(Json(resul));
        }
예제 #2
0
        public JsonResult Create(ProductDiscountDto dto)
        {
            var resul = new OperationResult(OperationResultType.Error);

            if (!string.IsNullOrEmpty(dto.DiscountName))
            {
                bool exis = _productDiscountContract.ProductDiscounts.Any(
                    c => c.DiscountName == dto.DiscountName && !c.IsDeleted && c.IsEnabled);
                if (exis)
                {
                    resul.Message = "已存在同名的折扣方案";
                    return(Json(resul));
                }
                dto.DiscountType = 3;
                resul            = _productDiscountContract.Insert(dto);
            }

            return(Json(resul));
        }
예제 #3
0
        public JsonResult Update(ProductDiscountDto dto)
        {
            var result = _productDiscountContract.Update(dto);

            return(Json(result));
        }
예제 #4
0
        public ActionResult Update(int Id)
        {
            ProductDiscountDto dto = _productDiscountContract.Edit(Id);

            return(View(dto));
        }