Example #1
0
        public async Task <IActionResult> DeleteBranch(int id)
        {
            try
            {
                //var worker = await _context.Worker.FindAsync(id);
                Branch oldBranch = await _branchRepo.GetBranch(id);

                if (oldBranch == null)
                {
                    return(NotFound());
                }
                ApplicationUser ExisttUser = await _userManager.FindByEmailAsync(oldBranch.BranchName);

                if (ExisttUser != null)
                {
                    IdentityResult result = await _userManager.DeleteAsync(ExisttUser);

                    if (result.Succeeded)
                    {
                        Branch branch = await _branchRepo.DeleteBranch(oldBranch.Id);

                        if (branch != null)
                        {
                            return(Ok(branch));
                        }
                        throw new NullReferenceException();
                    }
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
            return(BadRequest("Not found your Id"));
        }
        public HttpResponseMessage DeleteBranch(int deleteByID)
        {
            try
            {
                int i = branchRepository.DeleteBranch(deleteByID);

                if (i > 0)
                {
                    HttpResponseMessage hrm = new HttpResponseMessage(HttpStatusCode.NoContent)
                    {
                    };
                    return(hrm);
                }
                HttpResponseMessage hr = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                };
                return(hr);
            }
            catch (Exception ex)
            {
                Errors errors          = ErrorsHelper.GetErrors(ex);
                HttpResponseMessage hr = new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent(errors.ToString())
                };
                return(hr);
            }
        }
Example #3
0
        public IActionResult DeleteBranch(int id)
        {
            var branch = _branchRepository.FindBranchById(id);

            if (branch == null)
            {
                return(NotFound());
            }

            _branchRepository.DeleteBranch(branch);
            return(Ok());
        }
 public IActionResult DeleteBranch(int id)
 {
     try
     {
         int i = branchRepository.DeleteBranch(id);
         return(NoContent());
     }
     catch (Exception ex)
     {
         Errors errors = ErrorsHelper.GetErrors(ex);
         return(StatusCode(StatusCodes.Status500InternalServerError, errors));
     }
 }
 public HttpResponseMessage DeleteBranch(int id)
 {
     try
     {
         int i = branchRepository.DeleteBranch(id);
         return(Request.CreateResponse(HttpStatusCode.NoContent));
     }
     catch (Exception ex)
     {
         Errors errors = ErrorsHelper.GetErrors(ex);
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors));
     }
 }
        public ActionResult Delete(int id)
        {
            var status = _branchRepository.DeleteBranch(id);

            if (status == true)
            {
                return(RedirectToAction("Index", "Branches"));
            }
            else
            {
                ViewData["Message"] = "This branch cannot be deleted as it has existing rooms!";
                var listOfBranches = _branchRepository.GetBranches();
                return(View("Index", listOfBranches));
            }
        }
        public async Task <ApiResponse> DeleteBranch(long id)
        {
            var branchToDelete = await _branchRepo.FindBranchById(id);

            if (branchToDelete == null)
            {
                return(new ApiResponse(404));
            }

            if (!await _branchRepo.DeleteBranch(branchToDelete))
            {
                return(new ApiResponse(500));
            }

            return(new ApiOkResponse(true));
        }
Example #8
0
 public ActionResult Delete(int id)
 {
     try
     {
         var item = BranchRepository.GetBranchById(id);
         if (item != null)
         {
             BranchRepository.DeleteBranch(item.Id);
         }
         TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.DeleteSuccess;
         return(RedirectToAction("Diagrams", "Branch", new { area = "Staff" }));
     }
     catch (DbUpdateException)
     {
         TempData[Globals.FailedMessageKey] = App_GlobalResources.Error.RelationError;
         return(RedirectToAction("Diagrams", "Branch", new { area = "Staff" }));
     }
 }
Example #9
0
        public async Task <ActionResult <BranchVM> > DeleteBranch(int id)
        {
            try
            {
                var branchToDelete = await branchRepository.GetBranch(id);

                if (branchToDelete == null)
                {
                    return(NotFound($"Branch with Id = {id} not found"));
                }

                return(await branchRepository.DeleteBranch(id));
            }
            catch (DbUpdateException Ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  Ex.InnerException.Message));
            }
        }
Example #10
0
        public List <BranchModel> DeleteBranch(BranchModel aBranchModel)
        {
            List <BranchModel> branches;
            BaseViewModel      md = new BaseViewModel();

            md.CurrentCulture = aBranchModel.CurrentCulture;
            md.CurrentUserID  = aBranchModel.CurrentUserID;
            try
            {
                _branRepository.DeleteBranch(aBranchModel.ID);
                branches = GetAllBranchList(md);
            }
            catch (Exception ex)
            {
                IErrorLogService errorLog = new ErrorLogService();
                string           message  = ex.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message;
                errorLog.SetErrorLog(aBranchModel.CurrentUserID, "Branch", message);
                throw new Exception(ex.Message);
            }
            return(branches);
        }