示例#1
0
 public ActionResult Delete(string deleteID)
 {
     try
     {
         ISupplierService supplierService = UnityHelper.UnityResolve <ISupplierService>();
         var data = supplierService.DeleteSupplier(deleteID.Split(',').ToList());
         LogHelper.LogOperation(CurrentUserInfo.UserCode, string.Format("Delete SupplierInfo {0},{1}", deleteID, data));
         if (data > 0)
         {
             return(Content("OK"));
         }
         else
         {
             return(Content("Failed"));
         }
     }
     catch (BusinessException bex)
     {
         return(Content(bex.Message));
     }
     catch (Exception ex)
     {
         LogHelper.LogError(ex, "");
         return(Content(ex.Message));
     }
 }
示例#2
0
        //
        // GET: DeleteItem
        public ActionResult DeleteItem(string sid)
        {
            Guid supplierId;

            if (Guid.TryParse(sid, out supplierId))
            {
                Supplier supplier = supplierService.GetSupplier(supplierId);
                if (supplier != null)
                {
                    if (!string.IsNullOrWhiteSpace(supplier.LogoLocation))
                    {
                        var path = Path.Combine(Server.MapPath("~/App_Data/Logos"), supplier.LogoLocation);
                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                    }

                    if (supplierService.DeleteSupplier(supplierId))
                    {
                        ModelState.Clear();
                    }
                }
            }

            List <SupplierService.SupplierServiceView> suppliers = supplierService.GetSuppliers1(countryProg.Id);

            return(View("ListView", suppliers));
        }
        public IActionResult OnPost(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            _service.DeleteSupplier(id ?? default(int));

            return(RedirectToPage("./Index"));
        }
        public IActionResult Deletesupplier(Guid supplierID)
        {
            bool deleted = supplierService.DeleteSupplier(supplierID);

            if (deleted)
            {
                return(NoContent());
            }

            return(NotFound());
        }
示例#5
0
 public ActionResult Delete(long id)
 {
     try
     {
         _service.DeleteSupplier(id);
         return(NoContent());
     }
     catch (ArgumentOutOfRangeException)
     {
         return(BadRequest());
     }
     catch (KeyNotFoundException)
     {
         return(NotFound());
     }
 }
示例#6
0
        public void DeleteSupplierById_Service_Fail()
        {
            // Arrange
            supplierService = new SupplierService(mockRepository.Object, mockLogger.Object, mockCache.Object, mockTelemetry.Object);
            mockRepository.Setup(x => x.Delete <Supplier>(It.IsAny <int>())).Returns(false).Verifiable();

            // Act
            var response = supplierService.DeleteSupplier(It.IsAny <int>());

            // Assert
            Assert.IsNotNull(response);
            Assert.IsFalse(response.Result);
            Assert.IsTrue(response.Notifications.HasErrors());
            Assert.IsInstanceOfType(response, typeof(GenericServiceResponse <bool>));
            mockRepository.Verify(x => x.Delete <Supplier>(It.IsAny <int>()), Times.Once);
        }
示例#7
0
        // DELETE: api/Suppliers/5
        public async Task <HttpResponseMessage> Delete(int id)
        {
            try
            {
                SupplierDTO supplier = await _supplierService.DeleteSupplier(id);

                if (supplier == null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Not Found"));
                }
                return(Request.CreateResponse(HttpStatusCode.OK, supplier));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
        public ActionResult <SupplierDto> DeleteSupplier(int id)
        {
            var supplierDto = _supplierService.DeleteSupplier(id);

            if (supplierDto == null)
            {
                List <string> errorMessage = new List <string>();
                errorMessage.Add("Đã phát sinh lỗi, vui lòng thử lại");
                return(BadRequest(new ResponseDto(errorMessage, 500, "")));
            }
            List <string> successMessage = new List <string>();

            successMessage.Add("Xoá thành công");
            var responseDto = new ResponseDto(successMessage, 200, "");

            return(Ok(responseDto));
        }
        // GET: Supplier/Delete/{id}
        //Store Manager, Store Supervisor
        public ActionResult Delete(string id)
        {
            if (String.IsNullOrEmpty(id))
            {
                return(RedirectToAction("Index"));
            }

            if (supplierService.DeleteSupplier(id))
            {
                TempData["SuccessMessage"] = String.Format("Supplier '{0}' has been deleted", id);
            }
            else
            {
                TempData["ErrorMessage"] = String.Format("Cannot delete supplier '{0}'", id);
            }

            return(RedirectToAction("Index"));
        }
示例#10
0
        public ActionResult Delete(int id)
        {
            int result = 0;

            if (UserRolePermissionForPage.Delete == true)
            {
                result = _iCommonService.GetValidateReference("Supplier", id.ToString());
                if (result > 0)
                {
                    return(RedirectToAction(nameof(Index), new { noDelete = result }));
                }
                else
                {
                    var deletedid = _iSupplierService.DeleteSupplier(id);
                    return(RedirectToAction(nameof(Index)));
                }
            }
            else
            {
                return(RedirectToAction("NotFound", "Error"));
            }
        }
示例#11
0
 public IHttpActionResult DeleteSupplier(int idSupplier)
 {
     try
     {
         if (validator.validate((Request.Headers.GetValues("Authorization").FirstOrDefault()), UserRole.Administrator))
         {
             if (supplierService.DeleteSupplier(idSupplier))
             {
                 return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NoContent, "El proveedor ha sido eliminado")));
             }
             return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No se encntro el proveedor al que se hace referencia")));
         }
         else
         {
             return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "No posee los permisos necesarios")));
         }
     }
     catch (InvalidOperationException)
     {
         return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Debe ingresar el header Authorization")));
     }
 }
示例#12
0
        public IHttpActionResult Delete(int id)
        {
            try
            {
                // delete
                log.Debug("_supplierService.DeleteSupplier - supplierId: " + id + " ");

                _supplierService.DeleteSupplier(id);

                log.Debug("result: 'success'");

                //return JsonConvert.SerializeObject(true);
                return(Ok(true));
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
示例#13
0
        public async Task <IActionResult> Delete(int id)
        {
            await _service.DeleteSupplier(id);

            return(RedirectToAction(nameof(Index)));
        }
 // DELETE api/Suppliers/5
 public IHttpActionResult Delete(int id)
 {
     return(Ok(_supplierService.DeleteSupplier(id)));
 }
        public async Task <ActionResult> Delete(int id)
        {
            var response = await _supplierService.DeleteSupplier(id);

            return(Ok(response));
        }
示例#16
0
 public ActionResult Delete(Guid supplierId)
 {
     return(Json(_supplierService.DeleteSupplier(supplierId)));
 }
示例#17
0
 public void Delete(string mainCode, string subCode)
 {
     _supplierService.DeleteSupplier(mainCode, subCode);
 }
示例#18
0
        public async Task <IActionResult> DeleteSupplier(long id)
        {
            await _supplierService.DeleteSupplier(id);

            return(ApiResponder.RespondStatusCode(HttpStatusCode.OK));
        }
        public async Task <ActionResult <Supplier> > DeleteSupplier(Guid id)
        {
            var supplier = await _supplierService.DeleteSupplier(id);

            return(supplier);
        }