Beispiel #1
0
        public JsonResult SaveProduct(Product product)
        {
            ProductBO cls      = new ProductBO();
            bool      IsResult = cls.Save(product);

            return(Json(new { IsOk = IsResult }, JsonRequestBehavior.AllowGet));
        }
        //------------------- E.D.I.T.--------------------------------------------
        public static async Task EditEntityAsync(AuctionEditVM editVM, AuctionBO auctionBO, object userId, HttpPostedFileBase upload) //
        {
            var editBO = mapper.Map <AuctionBO>(editVM);                                                                              //1)из формы

            EditEntity(auctionBO, editBO, 0);

            //2)Product-----------------
            ProductBO productBO = DependencyResolver.Current.GetService <ProductBO>();

            productBO = productBO.LoadAll().FirstOrDefault(p => p.Title == editVM.Title);
            ProductBO productEdit = mapper.Map <ProductBO>(editVM);

            EditEntity(productBO, productEdit, 1);

            //3)BetAuction----------
            BetAuctionBO betAuctionBO = DependencyResolver.Current.GetService <BetAuctionBO>();

            betAuctionBO = betAuctionBO.LoadAll().Where(b => b.AuctionId == auctionBO.Id && b.ClientId == auctionBO.ActorId).FirstOrDefault();
            BetAuctionBO betEdit = mapper.Map <BetAuctionBO>(editVM);

            EditEntity(betAuctionBO, betEdit, 4);

            //4)Image----------------
            ImageBO imageBO = null;

            if (upload != null)
            {
                imageBO = DependencyResolver.Current.GetService <ImageBO>();
                imageBO = imageBO.LoadAll().FirstOrDefault(i => i.Id == auctionBO.Product.ImageId);
                if (imageBO != null)
                {
                    Image   image       = CreateImageEntity(editVM, upload, true); //true->edit
                    ImageBO editImageBO = mapper.Map <ImageBO>(image);
                    EditEntity(imageBO, editImageBO, 3);
                    imageBO.Save(imageBO);

                    //4)~recurs           //при редактир. нет новой записи ->переустанов. ссылок не треб.
                    //productBO.ImageId = newImageBO.Id;
                    productBO.Image = imageBO;
                }
            }
            productBO.Save(productBO);
            auctionBO.Product = productBO;
            auctionBO.Save(auctionBO);
        }
        public ResponseResult AddNewProduct(ProductDTO dto)
        {
            var a = ProductBO.Save(dto);

            return(a);
        }
Beispiel #4
0
 public JsonResult SaveProduct(Product product)
 {
     ProductBO cls = new ProductBO();
     bool IsResult = cls.Save(product);
     return Json(new { IsOk = IsResult }, JsonRequestBehavior.AllowGet);
 }
Beispiel #5
0
        public ResponseResult AddNewProduct()
        {
            var a = ProductBO.Save();

            return(a);
        }