Exemplo n.º 1
0
        // GET: Admin/Item/Delete/5
        public async Task <ActionResult> Delete(int?id, int?page, int?idItemType, int?pageSize)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Item item = await this.serviceItem.FindAsync(id);

            if (item == null)
            {
                return(HttpNotFound());
            }


            IServiceCustumerOrderItem serviceCustumerOrderItem = DependencyResolver.Current.GetService <ServiceCustumerOrderItem>();
            IServiceSupplierOffer     serviceSupplierOffer     = DependencyResolver.Current.GetService <ServiceSupplierOffer>();


            bool hasRelationOffers = serviceSupplierOffer.HasRelation(item);;
            bool hasRelationOrders = serviceCustumerOrderItem.HasRelation(item);

            this.ViewBag.hasRelationOffers = hasRelationOffers;
            this.ViewBag.hasRelationOrders = hasRelationOrders;


            this.ViewBag.page       = page;
            this.ViewBag.idItemType = idItemType;
            this.ViewBag.pageSize   = pageSize;

            return(View(item));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> DeleteConfirmed(int id, int?page, int?idItemType, int?pageSize)
        {
            Item item = await this.serviceItem.FindAsync(id);


            IServiceCustumerOrderItem serviceCustumerOrderItem = DependencyResolver.Current.GetService <ServiceCustumerOrderItem>();
            IServiceSupplierOffer     serviceSupplierOffer     = DependencyResolver.Current.GetService <ServiceSupplierOffer>();


            if (!serviceSupplierOffer.HasRelation(item) && !serviceCustumerOrderItem.HasRelation(item))
            {
                var listValuesToDelete = item.AttributeValues;

                int count = item.AttributeValues.Count();
                for (int i = 0; i < count; i++)
                {
                    this.serviceAttributeValue.Delete(item.AttributeValues[0]);
                }

                this.unitOfWorkAsync.SaveChanges();



                this.serviceItem.Delete(item);
                await this.unitOfWorkAsync.SaveChangesAsync();
            }



            return(RedirectToAction("Index", new { page = this.ViewBag.page, idItemType = this.ViewBag.idItemType, pageSiz = this.ViewBag.pageSize }));
        }
Exemplo n.º 3
0
 public CustumerController(IUnitOfWorkAsync unitOfWorkAsync,
                           IServiceUser serviceUser,
                           IServiceCustumerInfo serviceCustumerInfo,
                           IServiceCustumerOrder serviceCustumerOrder,
                           IServiceItemType serviceItemType,
                           IServiceTemplateItem serviceTemplateItem,
                           IServiceItem serviceItem,
                           IServiceCustumerOrderItem serviceCustumerOrderItem,
                           IServiceSupplierOffer serviceSupplierOffer)
 {
     this.unitOfWorkAsync          = unitOfWorkAsync;
     this.serviceUser              = serviceUser;
     this.serviceCustumerInfo      = serviceCustumerInfo;
     this.serviceCustumerOrder     = serviceCustumerOrder;
     this.serviceItemType          = serviceItemType;
     this.serviceTemplateItem      = serviceTemplateItem;
     this.serviceItem              = serviceItem;
     this.serviceCustumerOrderItem = serviceCustumerOrderItem;
     this.serviceSupplierOffer     = serviceSupplierOffer;
 }