Пример #1
0
        // GET: LeaveTypesController/Delete/5
        public ActionResult Delete(int id)
        {
            /* if (!_repo.isExists(id))
             * {
             *   return NotFound();
             * }
             * var leaveType = _repo.FindById(id);
             * var model = _mapper.Map<LeaveTypeVM>(leaveType);
             * return View(model);
             */

            var leaveType = _repo.FindById(id);

            if (leaveType == null)
            {
                return(NotFound());
            }
            var isSuccess = _repo.Delete(leaveType);

            if (!isSuccess)
            {
                return(BadRequest());
            }
            return(RedirectToAction(nameof(Index)));
        }
Пример #2
0
        // GET: LeaveTypesController/Delete/5
        public async Task <ActionResult> Delete(int id)
        {
            /*if (!_repo.Exists(id))
             * {
             *  return NotFound();
             * }
             * var obj = _repo.FindById(id);
             * var objVm = _mapper.Map<LeaveTypeVM>(obj);
             *
             * return View(objVm);*/

            var obj = await _repo.FindById(id);

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

            var Deleted = await _repo.Delete(obj);

            if (!Deleted)
            {
                return(BadRequest());
            }
            return(RedirectToAction(nameof(Index)));
        }
Пример #3
0
        // GET: LeaveTypes/Delete/5
        public async Task <ActionResult> Delete(int id)
        {
            //if (!_repo.Exists(id))
            //{
            //    return NotFound();
            //}

            //var leaveType = _repo.FindById(id);
            //var model = _mapper.Map<LeaveTypeVM>(leaveType);

            //return View(model);

            // copied from POST method even though it's a terrible idea to delete from a GET
            // this was done in the course
            var leaveType = await _repo.FindById(id);

            if (leaveType is null)
            {
                return(NotFound());
            }

            var success = await _repo.Delete(leaveType);

            if (!success)
            {
                return(BadRequest());
            }

            return(RedirectToAction(nameof(Index)));
        }
Пример #4
0
        // GET: LeaveTypes/Delete/5
        public ActionResult Delete(int id)
        {
            //if (!_repo.isExists(id))
            //{
            //    return NotFound();
            //}
            //var leaveType = _repo.FindById(id);
            //var model = _mapper.Map<LeaveTypeVM>(leaveType);
            //return View(model);


            // TODO: Add delete logic here
            var leaveType = _repo.FindById(id);

            if (leaveType == null)
            {
                return(NotFound());
            }
            var isSuccess = _repo.Delete(leaveType);

            if (!isSuccess)
            {
                ModelState.AddModelError("", "Something Went Wrong....");
                return(BadRequest());
            }

            return(RedirectToAction(nameof(Index)));
        }
        // GET: LeaveTypesController/Delete/5
        public ActionResult Delete(int id)
        {
            try
            {
                var entity = _repo.FindById(id.ToString());

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

                if (!_repo.Delete(entity))
                {
                    ModelState.AddModelError("", "Something went wrong....");
                    return(BadRequest());
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError("", "Something went wrong....");
                return(BadRequest());
            }
        }
        // GET: LeaveTypes/Delete/5
        public async Task <ActionResult> Delete(int id)
        {
            // TODO: Add delete logic here
            LeaveType locLeaveTypeRepositoryClass = await _ILeaveTypeRepository.FindByID(id);

            if (locLeaveTypeRepositoryClass == null)
            {
                return(NotFound());
            }
            bool isSuccess = await _ILeaveTypeRepository.Delete(locLeaveTypeRepositoryClass);

            return(RedirectToAction(nameof(Index)));
        }
        // GET: LeaveTypesController/Delete/5
        public ActionResult Delete(int id)
        {
            var leavetype = _repo.FindById(id);

            if (leavetype == null)
            {
                return(NotFound());
            }
            if (!_repo.Delete(leavetype))
            {
                return(BadRequest());
            }
            return(RedirectToAction(nameof(Index)));
        }
Пример #8
0
        // GET: LeaveTypesController/Delete/5
        public async Task <ActionResult> Delete(int id)
        {
            if (!await _repo.isExists(id))
            {
                return(NotFound());
            }

            var leavetype = await _repo.FindById(id);

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

            var isSuccess = await _repo.Delete(leavetype);

            if (!isSuccess)
            {
                return(BadRequest());
            }

            var allocation = await _AlloRepo.FindAll();

            if (allocation != null)
            {
                var AlloToDetete = allocation.ToList().Where(Q => Q.LeaveTypeId == id);

                foreach (var item in AlloToDetete)
                {
                    await _AlloRepo.Delete(item);
                }
            }


            var request = await _requestRepo.FindAll();

            if (allocation != null)
            {
                var requestToDetete = request.ToList().Where(Q => Q.LeaveTypeId == id);

                foreach (var item in requestToDetete)
                {
                    await _requestRepo.Delete(item);
                }
            }

            return(RedirectToAction(nameof(Index)));
        }
Пример #9
0
        public ActionResult Delete(int id, LeaveTypeVM model)
        {
            try
            {
                var leaveType = _repo.FindById(id);
                if (leaveType == null)
                {
                    return(NotFound());
                }

                var isSuccess = _repo.Delete(leaveType);
                if (!isSuccess)
                {
                    ModelState.AddModelError("", "Something went wrong!");
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError("", "Something went wrong!");
                return(View(model));
            }
        }
        public ActionResult Delete(LeaveTypeVM model)
        {
            try
            {
                if (!_repo.IsExists(model.Id))
                {
                    return(NotFound());
                }

                var LeaveType = _mapper.Map <LeaveType>(model);
                LeaveType = _repo.FindById(model.Id);

                var isSuccess = _repo.Delete(LeaveType);

                if (!isSuccess)
                {
                    ModelState.AddModelError("", "something went wrong");
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
        public async Task <ActionResult> Delete(int id, LeaveRequestViewModel model)
        {
            try
            {
                // TODO: Add delete logic here
                var leaveType = await _repo.FindById(id);

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

                var isSuccess = await _repo.Delete(leaveType);

                if (!isSuccess)
                {
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View(model));
            }
        }
Пример #12
0
        // GET: LeaveTypes/Delete/5
        public async Task <ActionResult> Delete(int id)
        {
            var leavetype = await _repo.FindById(id);

            if (leavetype == null)
            {
                return(NotFound());
            }
            var isSuccess = await _repo.Delete(leavetype);

            if (!isSuccess)
            {
                return(BadRequest());
            }
            return(RedirectToAction(nameof(Index)));
        }
        public ActionResult Delete(LeaveTypeVM model, int id)
        {
            try
            {
                // TODO: Add delete logic here
                var leavetype = _repo.FindById(id);

                if (leavetype == null)
                {
                    return(NotFound());
                }
                var isSuccessful = _repo.Delete(leavetype);

                if (!isSuccessful)
                {
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View(model));
            }
        }
Пример #14
0
 public OutputBase DeleteLeaveType(DeleteLeaveTypeInput input)
 {
     _leaveTypeRepository.Delete(input.LeaveTypeId);
     return(new OutputBase {
         Message = "Type deleted", Success = true
     });
 }
Пример #15
0
        // GET: LeaveTypesController/Delete/5
        public ActionResult Delete(int id)
        {
            var leaveType = _repo.FindById(id);

            if (!_repo.IsExists(id))
            {
                return(NotFound());
            }
            var result = _repo.Delete(leaveType);

            if (!result)
            {
                return(BadRequest());
            }
            return(RedirectToAction(nameof(Index)));
        }
        public async Task <bool> Delete(int leaveTypeId)
        {
            var entity = await _repository.FindById(leaveTypeId);

            entity.Delete();
            return(await _repository.Delete(entity));
        }
        // GET: LeaveTypes/Delete/5
        public ActionResult Delete(int id)
        {
            // TODO: Add delete logic here
            var leavetype = _repo.FindById(id);

            if (leavetype == null)
            {
                return(NotFound());
            }
            var isSuccess = _repo.Delete(leavetype);

            if (!isSuccess)
            {
                return(BadRequest());
            }
            return(RedirectToAction(nameof(Index)));
        }
Пример #18
0
        // GET: LeaveTypeController/Delete/5
        public async Task <ActionResult> Delete(int id)
        {
            var leavetype = await _repo.FindById(id);

            if (leavetype == null)
            {
                return(NotFound());
            }
            var isSuccess = await _repo.Delete(leavetype);

            if (!isSuccess)
            {
                ModelState.AddModelError("", "Something went wrong...");
                return(View());
            }
            return(RedirectToAction(nameof(Index)));
        }
        // GET: LeaveType/Delete/5
        public ActionResult Delete(string id)
        {
            var leaveType = _repo.FindById(id);

            if (leaveType == null)
            {
                return(NotFound());
            }
            var isSuccess = _repo.Delete(leaveType);

            if (!isSuccess)
            {
                return(BadRequest());
            }

            return(RedirectToAction(nameof(Index)));
        }
Пример #20
0
        // GET: LeaveTypesController/Delete/5
        public ActionResult Delete(int id)
        {
            var leavetype = _repo.FindById(id);

            if (leavetype == null)
            {
                return(NotFound());
            }
            var isSuccess = _repo.Delete(leavetype);

            if (!isSuccess)
            {
                ModelState.AddModelError("", "Something went wrong...");
                return(BadRequest());
            }
            return(RedirectToAction(nameof(Index)));
        }
Пример #21
0
        // GET: LeaveTypes/Delete/5
        public ActionResult Delete(int id)
        {
            // Make a pop up button instead of changing page - changing it in the view

            var leaveType = _repo.FindById(id);

            if (leaveType == null)
            {
                return(NotFound());
            }
            var isSuccess = _repo.Delete(leaveType);

            if (!isSuccess)
            {
                return(BadRequest());
            }
            return(RedirectToAction(nameof(Index)));
        }
        // GET: LeaveType/Delete/5
        public ActionResult Delete(int id)
        {
            var leaveType = _repository.FindById(id);

            if (leaveType == null)
            {
                return(NotFound());
            }
            var isSuccess = _repository.Delete(leaveType);

            if (!isSuccess)
            {
                ModelState.AddModelError("", "The Leave Type was not deleted...");
                return(BadRequest());
            }

            return(RedirectToAction(nameof(Index)));
        }
Пример #23
0
        // GET: LeaveTypesController/Delete/5
        public ActionResult Delete(int id)
        {
            LeaveType leaveType = repo.FindById(id);

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

            bool isSuccessful = repo.Delete(leaveType);

            if (!isSuccessful)
            {
                return(BadRequest());
            }

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> DeleteConfirmed(long id)
        {
            //var leaveType = await _context.LeaveTypes.FindAsync(id);
            //_context.LeaveTypes.Remove(leaveType);
            //await _context.SaveChangesAsync();
            var leaveType = leaveTypeRepository.GetDelete(id);
            await leaveTypeRepository.Delete(leaveType);

            return(RedirectToAction(nameof(Index)));
        }
Пример #25
0
        // GET: LeaveTypesController/Delete/5
        public ActionResult Delete(int id)
        {
            var leaveType = _repo.FindById(id);

            if (!_repo.isExisting(id))
            {
                //return RedirectToAction(nameof(Index));
                return(NotFound());
            }

            var isSuccess = _repo.Delete(leaveType);

            if (!isSuccess)
            {
                return(BadRequest());
            }

            return(RedirectToAction(nameof(Index)));
        }
Пример #26
0
        public ActionResult Delete(int id)
        {
            var apiResult = TryExecute(() =>
            {
                _leaveTypeRepository.Delete(id);
                _unitOfWork.Commit();
                return(true);
            }, "Leave Type deleted sucessfully");

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }
Пример #27
0
        public IActionResult DeleteLeaveType(long id)
        {
            LeaveType a = LeaveType_repo.Find(id);

            if (a == null)
            {
                return(NotFound());
            }
            LeaveType_repo.Delete(a);
            return(Ok());
        }
        public IActionResult Delete(Guid id)
        {
            var isSuccess = _repository.Delete(_repository.FindById(id));

            if (isSuccess)
            {
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Something went Wrong");
            return(RedirectToAction("Index"));
        }
 public bool Delete(int id)
 {
     if (string.IsNullOrWhiteSpace(id.ToString()))
     {
         return(false);
     }
     else
     {
         return(iLeaveTypeRepository.Delete(id));
     }
 }
 // GET: LeaveTypes/Delete/5
 public ActionResult Delete(int id)
 {
     try
     {
         if (!_repo.isExists(id))
         {
             return(NotFound());
         }
         var leavetype = _repo.FindById(id);
         var isSuccess = _repo.Delete(leavetype);
         var model     = _mapper.Map <LeaveTypeVM>(leavetype);
         if (!isSuccess)
         {
             return(BadRequest());
         }
         return(RedirectToAction(nameof(Index)));
     } catch
     {
         return(View());
     }
 }