Ejemplo n.º 1
0
        public ActionResult DeleteProvider(List <int> deleteItem)
        {
            MessageViewModels response = new MessageViewModels();

            try
            {
                foreach (var id in deleteItem)
                {
                    AroundProvider provider = _aroundProviderService.FindById(id);
                    if (null != provider)
                    {
                        List <AroundProviderProduct> products = provider.AroundProviderProducts.ToList();
                        provider.AroundProviderProducts = null;
                        _aroundProviderService.Delete(provider);
                        foreach (var p in products)
                        {
                            AroundProviderProduct product = _aroundProviderProductService.FindById(p.Id);
                            if (null != product)
                            {
                                _aroundProviderProductService.Delete(product);
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                response.StatusCode = -1;
                return(Json(response));
            }
            return(Json(response));
        }
Ejemplo n.º 2
0
        public ActionResult UpdateProduct(ProductModel productModel)
        {
            MessageViewModels response = new MessageViewModels();
            AroundProvider    provider = _aroundProviderService.FindById(productModel.SrvProvId);

            if (null != provider)
            {
                AroundProviderProduct product = _aroundProviderProductService.FindById(productModel.Id);
                if (null != product)
                {
                    product.Name         = productModel.Name;
                    product.ImgUrl       = productModel.ImageUrl;
                    product.Price        = productModel.Price;
                    product.LastModified = DateTime.Now;
                    _aroundProviderProductService.Update(product);
                }
                else
                {
                    response.StatusCode = -1;
                }
            }
            else
            {
                response.StatusCode = -1;
            }
            return(Json(response));
        }
Ejemplo n.º 3
0
        public void DeleteById(int id)
        {
            AroundProviderProduct e = _repository.FindById(id);

            if (e != null)
            {
                _repository.Update(e);
            }
        }
Ejemplo n.º 4
0
        public ActionResult GetProductDetail(int productId)
        {
            MessageViewModels     response = new MessageViewModels();
            AroundProviderProduct product  = _aroundProviderProductService.FindById(productId);

            if (null != product)
            {
                ProductModel proModel = null;
                proModel                = new ProductModel();
                proModel.Id             = product.Id;
                proModel.Name           = product.Name;
                proModel.Price          = product.Price.Value;
                proModel.ImageUrl       = product.ImgUrl;
                proModel.CreateDate     = product.CreateDate.Value.ToString(AmsConstants.DateFormat);
                proModel.CreateDateLong = product.CreateDate.Value.Ticks;
                proModel.SrvProvId      = product.AroundProviderId.Value;
                response.Data           = proModel;
            }
            else
            {
                response.StatusCode = -1;
            }
            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
 public void Delete(AroundProviderProduct e)
 {
     _repository.Delete(e);
 }
Ejemplo n.º 6
0
 public void Update(AroundProviderProduct e)
 {
     _repository.Update(e);
 }
Ejemplo n.º 7
0
 public void Add(AroundProviderProduct e)
 {
     _repository.Add(e);
 }