public object DeleteConfirmation(DeleteConfirmationViewModel deleteConfirmationViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, new BaseResponse(ResponseStatus.ValidationError.ToString(), ModelState.Values.ToList()[0].Errors[0].ErrorMessage)));
            }

            CurrentUserInfo currentUserInfo = _tokenHelper.GetUserInfo();

            if (!_projectLogic.IsProjectExist(currentUserInfo.Id, deleteConfirmationViewModel.ProjectId))
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, new BaseResponse(ResponseStatus.Notfound.ToString(), ResponseMessagesModel.ProjectNotFound)));
            }

            //TODO: check if in this day there is any report!!!!

            if (!_confirmationLogic.IsReportConfirmedBy(deleteConfirmationViewModel.ProjectId, currentUserInfo.Id, deleteConfirmationViewModel.ReportDate))
            {
                return(Request.CreateResponse(HttpStatusCode.Conflict, new BaseResponse(ResponseStatus.ValidationError.ToString(), ResponseMessagesModel.ConfirmationNotFound)));
            }

            ConfirmationData confirmationData =
                DeleteConfirmationViewModel.GetConfirmationData(currentUserInfo.Id, deleteConfirmationViewModel);

            _confirmationLogic.Delete(confirmationData);

            return(Request.CreateResponse(HttpStatusCode.OK, new BaseResponse(ResponseStatus.Success.ToString(), ResponseMessagesModel.Success)));
        }
Ejemplo n.º 2
0
        public void Validate_DeleteConfirmed_ShouldBeValidated(bool?deleteConfirmed, bool expectedValid)
        {
            var model = new DeleteConfirmationViewModel {
                DeleteConfirmed = deleteConfirmed
            };

            AssertValidationResult(request => request.DeleteConfirmed, model, expectedValid);
        }
Ejemplo n.º 3
0
        public void Validate_ProviderId_ShouldBeValidated(int providerId, bool expectedValid)
        {
            var model = new DeleteConfirmationViewModel {
                ProviderId = providerId
            };

            AssertValidationResult(request => request.ProviderId, model, expectedValid);
        }
Ejemplo n.º 4
0
        public void Validate_ApprenticeshipHashedId_ShouldBeValidated(string apprenticeshipHashedId, bool expectedValid)
        {
            var model = new DeleteConfirmationViewModel()
            {
                DraftApprenticeshipHashedId = apprenticeshipHashedId
            };

            AssertValidationResult(request => request.DraftApprenticeshipHashedId, model, expectedValid);
        }
Ejemplo n.º 5
0
        public IActionResult DeleteConfirmation(int id, int userid) //LAB 24
        {
            var viewModel = new DeleteConfirmationViewModel();

            viewModel.ItemId = id;
            viewModel.UserId = userid;

            return(View(viewModel));
        }
 public void Delete(SpecializationDTO specialization)
 {
     IWindowManager manager = new WindowManager();
     DeleteConfirmationViewModel modify = new DeleteConfirmationViewModel();
     bool? showDialogResult = manager.ShowDialog(modify, null, null);
     if (showDialogResult != null && showDialogResult == true)
     {
         SpecializationService.Delete(specialization);
     }
     Reload();
 }
Ejemplo n.º 7
0
        public DeleteConfirmationViewModel DeleteConfirmationForm(int id)
        {
            NoiseProtection             noiseProtection = _noiseProtectionDAO.Get(id);
            DeleteConfirmationViewModel viewModel       = new DeleteConfirmationViewModel
            {
                Id    = "trans" + noiseProtection.Id,
                Title = noiseProtection.Title
            };

            return(viewModel);
        }
Ejemplo n.º 8
0
        public DeleteConfirmationViewModel DeleteConfirmationForm(string id)
        {
            Administrator administrator           = _adminDAO.Get(id);
            DeleteConfirmationViewModel viewModel = new DeleteConfirmationViewModel
            {
                Id    = administrator.Username,
                Title = administrator.Username
            };

            return(viewModel);
        }
Ejemplo n.º 9
0
        public DeleteConfirmationViewModel DeleteConfirmationForm(int id)
        {
            HelicopterType helicopterType         = _helicopterTypeDAO.Get(id);
            DeleteConfirmationViewModel viewModel = new DeleteConfirmationViewModel
            {
                Id    = helicopterType.Id.ToString(CultureInfo.InvariantCulture),
                Title = helicopterType.Title
            };

            return(viewModel);
        }
        public DeleteConfirmationViewModel DeleteConfirmationForm(int id)
        {
            NoiseProtectionDefinition   definintion = _noiseProtectionDefinitionDAO.Get(id);
            DeleteConfirmationViewModel viewModel   = new DeleteConfirmationViewModel
            {
                Id    = definintion.Id.ToString(CultureInfo.InvariantCulture),
                Title = definintion.SystemName
            };

            return(viewModel);
        }
Ejemplo n.º 11
0
        public DeleteConfirmationViewModel DeleteConfirmationForm(int id)
        {
            var helicopterTask = _helicopterTaskDAO.Get(id);
            var viewModel      = new DeleteConfirmationViewModel
            {
                Id    = helicopterTask.Id.ToString(CultureInfo.InvariantCulture),
                Title = helicopterTask.ToString()
            };

            return(viewModel);
        }
        public void Delete(EquipmentTypeDTO equipmentType)
        {
            IWindowManager manager             = new WindowManager();
            DeleteConfirmationViewModel modify = new DeleteConfirmationViewModel();
            bool?showDialogResult = manager.ShowDialog(modify, null, null);

            if (showDialogResult != null && showDialogResult == true)
            {
                EquipmentTypeService.Delete(equipmentType);
            }
            Reload();
        }
Ejemplo n.º 13
0
        public DeleteConfirmationViewModel DeleteConfirmationForm(int id)
        {
            Rotation rotation = _rotationDAO.Get(id);

            DeleteConfirmationViewModel viewModel = new DeleteConfirmationViewModel
            {
                Id    = "trans" + rotation.Id,
                Title = rotation.Task.Title
            };

            return(viewModel);
        }
Ejemplo n.º 14
0
        public DeleteConfirmationViewModel DeleteConfirmationForm(int id)
        {
            var helicopterWorkCategory = _helicopterWorkCategoryDAO.Get(id);

            var viewModel = new DeleteConfirmationViewModel
            {
                Id    = helicopterWorkCategory.Id.ToString(CultureInfo.InvariantCulture),
                Title = helicopterWorkCategory.Title
            };

            return(viewModel);
        }
Ejemplo n.º 15
0
        public void Delete(RankDTO rank)
        {
            IWindowManager manager             = new WindowManager();
            DeleteConfirmationViewModel modify = new DeleteConfirmationViewModel();
            bool?showDialogResult = manager.ShowDialog(modify, null, null);

            if (showDialogResult != null && showDialogResult == true)
            {
                RankService.Delete(rank);
            }
            Reload();
        }
Ejemplo n.º 16
0
        public ActionResult Delete(int id)
        {
            var viewModel = new DeleteConfirmationViewModel
            {
                DeleteEntityId       = id,
                HeaderText           = "Slider",
                PostDeleteAction     = "DeleteConfirmed",
                PostDeleteController = "Slider"
            };

            return(PartialView("_DeleteConfirmation", viewModel));
        }
Ejemplo n.º 17
0
        public DeleteConfirmationViewModel DeleteConfirmationForm(int id)
        {
            Task task = _taskDAO.Get(id);

            DeleteConfirmationViewModel viewModel = new DeleteConfirmationViewModel
            {
                Id    = "trans" + task.Id,
                Title = task.Title
            };

            return(viewModel);
        }
Ejemplo n.º 18
0
        public void Delete(MissionDTO mission)
        {
            IWindowManager manager             = new WindowManager();
            DeleteConfirmationViewModel modify = new DeleteConfirmationViewModel();
            bool?showDialogResult = manager.ShowDialog(modify, null, null);

            if (showDialogResult != null && showDialogResult == true)
            {
                mission.InformObservers();
                MissionService.Delete(mission);
            }
            Reload();
        }
        public void Arrange()
        {
            var _autoFixture = new Fixture();

            _request         = _autoFixture.Create <DeleteConfirmationRequest>();
            _modelMapperMock = new Mock <IModelMapper>();
            _viewModel       = _autoFixture.Create <DeleteConfirmationViewModel>();

            _modelMapperMock
            .Setup(x => x.Map <DeleteConfirmationViewModel>(_request))
            .ReturnsAsync(_viewModel);

            Sut = new DraftApprenticeshipController(Mock.Of <IMediator>(), Mock.Of <ICommitmentsApiClient>(), _modelMapperMock.Object, Mock.Of <IEncodingService>());
        }
Ejemplo n.º 20
0
        public ActionResult DeleteConfirmed(DeleteConfirmationViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_DeleteConfirmation", viewModel));
            }
            var entity = _webSitePageStoreBase.GetById(viewModel.DeleteEntityId);

            if (entity == null)
            {
                return(Json(new { success = true }));
            }
            _webSitePageStoreBase.Delete(entity);
            return(Json(new { success = true }));
        }
Ejemplo n.º 21
0
        public IActionResult DeleteLeague(int id)
        {
            var controller = this.ControllerContext.ActionDescriptor.RouteValues["controller"];
            var area       = this.ControllerContext.ActionDescriptor.RouteValues["area"];

            DeleteConfirmationViewModel model = new DeleteConfirmationViewModel()
            {
                Id          = id,
                ItemName    = controller,
                CancelPath  = UrlBuilder.GetUrl(controller, nameof(All), area: area),
                DestroyPath = UrlBuilder.GetUrl(controller, nameof(DestroyLeague), id.ToString(), area)
            };

            return(View("DeleteConfirmationView", model));
        }
Ejemplo n.º 22
0
        public ActionResult DeleteNews(DeleteConfirmationViewModel model)
        {
            if (model.DeletedId != 0)

            {
                var deletedItem = blService.DatabaseService.NewsRepository.Get(model.DeletedId);
                if (deletedItem != null)
                {
                    blService.DatabaseService.NewsRepository.Delete(deletedItem);
                    blService.DatabaseService.Save();
                }
            }


            return(RedirectToAction("News"));
        }
Ejemplo n.º 23
0
        public PartialViewResult DeleteStudent(DeleteConfirmationViewModel deleteConfirmationViewModel)
        {
            bool             success = false;
            MessageViewModel message = new MessageViewModel();

            if (ModelState.IsValid)
            {
                success = _studentService.DeleteStudent(deleteConfirmationViewModel.DeleteEntityID);
            }
            if (success)
            {
                message.MessageType = EMessageType.Success;
                message.MessageText = string.Format(AppMessage.DATA_DELETED_SUCCESS_FULLY, "Student");
                message.ClassName   = AppConstant.SUCCESS_CLASS;
            }
            return(PartialView("_Message", message));
        }
Ejemplo n.º 24
0
        public ActionResult DeleteConfirmed(DeleteConfirmationViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var entity = PageManager.FindById(viewModel.DeleteEntityId);
                if (entity == null)
                {
                    return(Json(new { success = true }));
                }

                PageManager.DeletePage(viewModel.DeleteEntityId);

                return(Json(new { success = true }));
            }

            return(PartialView("_DeleteConfirmation", viewModel));
        }
        public async Task <ActionResult> DeleteConfirmation(DeleteConfirmationViewModel viewModel)
        {
            if (viewModel.DeleteConfirmed != null && !viewModel.DeleteConfirmed.Value)
            {
                return(RedirectToAction("ViewEditDraftApprenticeship", "DraftApprenticeship", new DraftApprenticeshipRequest
                {
                    ProviderId = viewModel.ProviderId,
                    CohortReference = viewModel.CohortReference,
                    DraftApprenticeshipHashedId = viewModel.DraftApprenticeshipHashedId
                }));
            }

            await _commitmentsApiClient.DeleteDraftApprenticeship(viewModel.CohortId, viewModel.DraftApprenticeshipId, new DeleteDraftApprenticeshipRequest(), CancellationToken.None);

            TempData.AddFlashMessage(DraftApprenticeDeleted, ITempDataDictionaryExtensions.FlashMessageLevel.Success);
            return(RedirectToAction("Details", "Cohort", new { viewModel.ProviderId, viewModel.CohortReference }));
        }
Ejemplo n.º 26
0
        public IActionResult DeleteRound(int roundId, int seasonId)
        {
            var controller = this.ControllerContext.ActionDescriptor.RouteValues["controller"].ToLower();
            var area       = this.ControllerContext.ActionDescriptor.RouteValues["area"];
            Dictionary <string, string> additionalParams = new Dictionary <string, string>()
            {
                { nameof(seasonId), seasonId.ToString() }
            };
            DeleteConfirmationViewModel model = new DeleteConfirmationViewModel()
            {
                Id          = roundId,
                ItemName    = Round,
                CancelPath  = UrlBuilder.GetUrl(controller, nameof(All), area: area, additionalParameters: additionalParams),
                DestroyPath = UrlBuilder.GetUrl(controller, nameof(DestroyRound), roundId.ToString(), area, additionalParameters: additionalParams)
            };

            return(View("DeleteConfirmationView", model));
        }
Ejemplo n.º 27
0
        public async Task <ActionResult> DeleteConfirmation(DeleteConfirmationViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            if (viewModel.DeleteConfirmed != null && !viewModel.DeleteConfirmed.Value)
            {
                return(Redirect(_providerUrlhelper.ProviderCommitmentsLink($"{viewModel.ProviderId}/unapproved/{viewModel.HashedCommitmentId}/apprentices/{viewModel.HashedApprenticeshipId}/edit")));
            }

            var deletedApprenticeshipName = await _commitmentOrchestrator.DeleteApprenticeship(CurrentUserId, viewModel, GetSignedInUser());

            SetInfoMessage($"Apprentice record for {deletedApprenticeshipName} deleted", FlashMessageSeverityLevel.Okay);

            return(RedirectToRoute("CohortDetails", new { providerId = viewModel.ProviderId, hashedCommitmentId = viewModel.HashedCommitmentId }));
        }
Ejemplo n.º 28
0
        public static MvcHtmlString DeleteConfirmation <T>(this HtmlHelper <T> helper, string modalId,
                                                           string actionDelete, string controller)
            where T : BaseViewModel
        {
            string        modalLabel           = MvcHtmlString.Create(helper.ViewData.ModelMetadata.ModelType.Name.ToLower() + "-delete-confirmation-title").ToHtmlString();
            StringBuilder builder              = new StringBuilder();
            var           deleteConfirmationVm = new DeleteConfirmationViewModel
            {
                Id           = helper.ViewData.Model.Id,
                ActionDelete = actionDelete,
                Controller   = controller,
                WindowId     = modalLabel
            };

            builder.AppendLine(string.Format("<div class=\"modal fade\" id={0} tabindex=\"-1\" role=\"dialog\" aria-labelledby={1} >", modalId, modalLabel));
            builder.AppendLine(helper.Partial("_DeleteConfirmation", deleteConfirmationVm).ToHtmlString());
            builder.AppendLine("</div>");
            return(MvcHtmlString.Create(builder.ToString()));
        }
Ejemplo n.º 29
0
        public ActionResult Delete(int id)
        {
            //var pageHaveChildern = PageManager.FindById(id);

            //if (pageHaveChildern.ChildernPages.Any())
            //{
            //    ModelState.AddModelError("", " لايمكن حذف ");
            //}

            var viewModel = new DeleteConfirmationViewModel
            {
                DeleteEntityId       = id,
                HeaderText           = "Pages",
                PostDeleteAction     = "DeleteConfirmed",
                PostDeleteController = "PagesAdmin"
            };

            return(PartialView("_DeleteConfirmation", viewModel));
        }
Ejemplo n.º 30
0
 public PartialViewResult DeleteStudent(string code)
 {
     if (code.Length <= 0 || code.Equals("0"))
     {
         MessageViewModel message = new MessageViewModel();
         //courseViewModel.FormTitle = "Add Course";
         return(PartialView("_Message", message));
     }
     else
     {
         DeleteConfirmationViewModel deleteConfirmationViewModel = new DeleteConfirmationViewModel();
         Student student = _studentService.GetStudentByCode(code);
         deleteConfirmationViewModel.DeleteEntityID       = student.StudentID;
         deleteConfirmationViewModel.HeaderText           = "Delete Student?";
         deleteConfirmationViewModel.PostDeleteController = "Student";
         deleteConfirmationViewModel.PostDeleteAction     = "DeleteStudent";
         deleteConfirmationViewModel.DeleteMessage        = string.Format(AppMessage.DELETE_CONFIRMATION, "student");
         return(PartialView("_DeleteConfirmation", deleteConfirmationViewModel));
     }
 }