public void Excluir(Guid id)
        {
            var material = _materialService.GetById(id);

            _materialService.Delete(material);
            Commit();
        }
Beispiel #2
0
 public async Task <IActionResult> Delete(int id)
 {
     if (await _materialService.Delete(id))
     {
         return(NoContent());
     }
     throw new Exception("Error deleting the Material");
 }
        public ActionResult DelPic(int id)
        {
            var            model      = materialservice.GetModel(id);
            int            num        = materialservice.Delete(id);
            ResultJsonInfo resultInfo = new ResultJsonInfo();

            if (num > 0)
            {
                System.IO.File.Delete(Server.MapPath(model.topimg));
                resultInfo.Result = true;
                resultInfo.Msg    = "删除成功";
            }
            else
            {
                resultInfo.Result = false;
                resultInfo.Msg    = "删除失败";
            }
            return(Json(resultInfo));
        }
Beispiel #4
0
        public HttpResponseMessage Delete(HttpRequestMessage request, int id)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var oldMaterial = _materialService.Delete(id);
                    _materialService.Save();

                    var responseData = Mapper.Map <Material, MaterialViewModel>(oldMaterial);
                    response = request.CreateResponse(HttpStatusCode.Created, responseData);
                }

                return response;
            }));
        }
Beispiel #5
0
 public override void OnBtnCommand(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     // MessageBox.Show(e.Item.Caption);
     //新增
     if (e.Item.Caption == BtnCommandEnum.Add)
     {
         eRPM002MaterialBindingSource.AddNew();
         EditForm(this.Text + "新增", BtnCommandEnum.Add);
     }
     else if (e.Item.Caption == BtnCommandEnum.Edit)
     {
         EditForm(this.Text + "修改", BtnCommandEnum.Edit);
     }
     else if (e.Item.Caption == BtnCommandEnum.Delete)
     {
         if (ERPHelper.Instance.MessageDel())
         {
             var temp = eRPM002MaterialBindingSource.Current as ERP_M002_Material;
             materialService.Delete(temp.Id);
             eRPM002MaterialBindingSource.RemoveCurrent();
         }
     }
 }
Beispiel #6
0
        /// <summary>
        /// Gọi khi xóa 1 material
        /// </summary>
        /// <param name="id">id của record được chọn vào</param>
        /// <returns></returns>
        public JsonResult Delete(int id)
        {
            string message = string.Empty;
            bool   status;

            materialService.Delete(id);
            try
            {
                materialService.Save();
                status = true;
            }
            catch (SqlException sEx)
            {
                message = sEx.Message;
                status  = false;
            }

            return(Json(new
            {
                status = status,
                message = message
            }, JsonRequestBehavior.AllowGet));
        }
        private static void DeleteAllDict()
        {
            var dealVariantServiceEntities = dealVariantService.GetAll();

            foreach (var dealVariantServiceEntity in dealVariantServiceEntities)
            {
                if (dealVariantService.IsPossibilityToDelete(dealVariantServiceEntity))
                {
                    dealVariantService.Delete(dealVariantServiceEntity);
                }
            }

            var streetServiceEntities = streetService.GetAll();

            foreach (var streetServiceEntity in streetServiceEntities)
            {
                if (streetService.IsPossibilityToDelete(streetServiceEntity))
                {
                    streetService.Delete(streetServiceEntity);
                }
            }

            var districtServiceEntities = districtService.GetAll();

            foreach (var districtServiceEntity in districtServiceEntities)
            {
                if (districtService.IsPossibilityToDelete(districtServiceEntity))
                {
                    districtService.Delete(districtServiceEntity);
                }
            }
            var floorLevelServiceEntities = floorLevelService.GetAll();

            foreach (var floorLevelServiceEntity in floorLevelServiceEntities)
            {
                if (floorLevelService.IsPossibilityToDelete(floorLevelServiceEntity))
                {
                    floorLevelService.Delete(floorLevelServiceEntity);
                }
            }
            var layoutServiceEntities = layoutService.GetAll();

            foreach (var layoutServiceEntity in layoutServiceEntities)
            {
                if (layoutService.IsPossibilityToDelete(layoutServiceEntity))
                {
                    layoutService.Delete(layoutServiceEntity);
                }
            }
            var materialServiceEntities = materialService.GetAll();

            foreach (var materialServiceEntity in materialServiceEntities)
            {
                if (materialService.IsPossibilityToDelete(materialServiceEntity))
                {
                    materialService.Delete(materialServiceEntity);
                }
            }
            var ownershipServiceEntities = ownershipService.GetAll();

            foreach (var ownershipServiceEntity in ownershipServiceEntities)
            {
                if (ownershipService.IsPossibilityToDelete(ownershipServiceEntity))
                {
                    ownershipService.Delete(ownershipServiceEntity);
                }
            }
            var realtorServiceEntities = realtorService.GetAll();

            foreach (var realtorServiceEntity in realtorServiceEntities)
            {
                if (realtorService.IsPossibilityToDelete(realtorServiceEntity))
                {
                    realtorService.Delete(realtorServiceEntity);
                }
            }
            var sewageServiceEntities = sewageService.GetAll();

            foreach (var sewageServiceEntity in sewageServiceEntities)
            {
                if (sewageService.IsPossibilityToDelete(sewageServiceEntity))
                {
                    sewageService.Delete(sewageServiceEntity);
                }
            }


            var terraceServiceEntities = terraceService.GetAll();

            foreach (var terraceServiceEntity in terraceServiceEntities)
            {
                if (terraceService.IsPossibilityToDelete(terraceServiceEntity))
                {
                    terraceService.Delete(terraceServiceEntity);
                }
            }
            var toiletTypeServiceEntities = toiletTypeService.GetAll();

            foreach (var toiletTypeServiceEntity in toiletTypeServiceEntities)
            {
                if (toiletTypeService.IsPossibilityToDelete(toiletTypeServiceEntity))
                {
                    toiletTypeService.Delete(toiletTypeServiceEntity);
                }
            }
            var waterSupplyServiceEntities = waterSupplyService.GetAll();

            foreach (var waterSupplyServiceEntity in waterSupplyServiceEntities)
            {
                if (waterSupplyService.IsPossibilityToDelete(waterSupplyServiceEntity))
                {
                    waterSupplyService.Delete(waterSupplyServiceEntity);
                }
            }
        }
Beispiel #8
0
        public async Task <IActionResult> Delete(int id)
        {
            var result = await _materialService.Delete(id);

            return(Ok(result));
        }