public ActionResult DeleteDealer(int id)
        {
            if (id > 0)
            {
                try
                {
                    _reagentService.DeleteDealer(id);
                }
                catch (DbUpdateException ex) when((ex.GetBaseException() as SqlException).Number == 547)
                {
                    Program.Logger.Error(ex);
                    return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.foreignConstraintFailed, "Failed", "This field is being used by some other reference. Please delete the reference first before deleting this."))));
                }
                catch (Exception e)
                {
                    Program.Logger.Error(e);
                    return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "Failed", "Error occurred while deleting the dealer details"))));
                }

                return(Ok(GetResponse(ResponseType.ACK, ResponseStatusCode.SUCCESS)));
            }
            else
            {
                return(BadRequest(GetResponse(ResponseType.ERROR, ResponseStatusCode.ERROR, GetError(ErrorCodes.invalidData, "Invalid input", "Please enter proper dealer details"))));
            }
        }
Beispiel #2
0
        protected async override void DeleteModelItem(Dealers model)
        {
            IsBusy = Visibility.Visible;
            var response = await _reagentService.DeleteDealer(model);

            IsBusy = Visibility.Hidden;

            if (response != null && response.Acknowledgement != null)
            {
                if (response.Acknowledgement.Status.Equals(ResponseStatusCode.success.ToString()))
                {
                    GetModelItems();
                }
                else
                {
                    MessageBox.Show("Failed deleting the dealer", "Error");
                }
            }
        }