public async Task <IActionResult> SaveDraftAsync(ReturnViewModel postedReturnViewModel) { #region Check user, then retrieve model from Session var checkResult = await CheckUserRegisteredOkAsync(); if (checkResult != null) { return(checkResult); } var stashedReturnViewModel = UnstashModel <ReturnViewModel>(); #endregion postedReturnViewModel.ReportInfo = stashedReturnViewModel.ReportInfo; ExcludeBlankFieldsFromModelState(postedReturnViewModel); ConfirmPayBandsAddUpToOneHundred(postedReturnViewModel); ValidateBonusIntegrity(postedReturnViewModel); if (!ModelState.IsValid) { this.CleanModelErrors <ReturnViewModel>(); return(View(postedReturnViewModel.OriginatingAction, postedReturnViewModel)); } await _SubmissionPresenter.UpdateDraftFileAsync(VirtualUser.UserId, postedReturnViewModel); await _SubmissionPresenter.CommitDraftFileAsync(postedReturnViewModel); return(View("DraftComplete", postedReturnViewModel)); }
public ActionResult Return(ReturnViewModel viewModel) { var booking = _bookingRepository.GetByBookingNumber(viewModel.BookingNumber); var request = _returnViewModelMapper.Map(viewModel); if (booking == null) { ModelState.AddModelError("BookingNumber", "No booking could be found matching the specified booking number."); } else { var validationMessages = booking.ValidateReturn(request); validationMessages.ForEach(validationMessage => ModelState.AddModelError(validationMessage.Field, validationMessage.Text)); } if (!ModelState.IsValid) { //_makeViewModelMapper.Hydrate(viewModel); return(View("Collect", viewModel)); } booking.Return(request); _bookingRepository.Update(booking); return(RedirectToAction("ReturnSuccess")); }
public async Task <IActionResult> AlterarFlagFavoritoAsync(FavoritarViewModel model) { ReturnViewModel retorno = new ReturnViewModel(); try { bool result = false; if (model.Objeto == ObjectsEnum.Edital.ToString()) { result = await _editalService.AlterarFlagFavoritoAsync(model); } else if (model.Objeto == ObjectsEnum.Sentenca.ToString()) { } if (!result) { retorno.MensagemErro = "Não foi possível Favoritar/Desfavoritar esse item!"; } retorno.Sucesso = result; } catch (Exception) { retorno.Sucesso = false; retorno.MensagemErro = "Erro, tente novamente!"; } return(Json(retorno)); }
public async Task <IActionResult> SelecionarPublicacaoAsync(PublicacaoSelecionarViewModel model) { ReturnViewModel retorno = new ReturnViewModel(); try { bool result = false; if (model.TpPublicacao == Convert.ToInt32(ObjectsEnum.Edital).ToString()) { result = await _editalService.IncluiEditalAsync(model); } else if (model.TpPublicacao == Convert.ToInt32(ObjectsEnum.Sentenca).ToString()) { } if (!result) { retorno.MensagemErro = "Não foi selecionar esse item!"; } retorno.Sucesso = result; } catch (Exception) { retorno.Sucesso = false; retorno.MensagemErro = "Erro, tente novamente!"; } return(Json(retorno)); }
public ReturnViewModel Create(UserBaseModel model) { var result = new ReturnViewModel(); var entity = new User { Name = model.UserName, Email = model.Email, Balance = model.Balance, RoleId = model.RoleId, GroupId = model.GroupId, AddedOn = DateTime.Now }; try { _repository.Create(entity); } catch (Exception ex) { result.Message = ex.Message; return(result); } result.Message = entity.Id.ToString(); result.IsSuccess = true; return(result); }
public ReturnViewModel Update(UserViewModel model) { var result = new ReturnViewModel(); var entity = _repository.GetById(model.UserId); if (entity == null) { result.Message = "user not found"; return(result); } entity.Name = model.UserName; entity.Email = model.Email; entity.Balance = model.Balance; entity.RoleId = model.RoleId; entity.GroupId = model.GroupId; entity.ModifiedOn = DateTime.Now; try { _repository.Update(entity); } catch (Exception ex) { result.Message = ex.Message; return(result); } result.IsSuccess = true; return(result); }
public async Task <IActionResult> EnterCalculations(ReturnViewModel postedReturnViewModel, string returnUrl = null) { #region Check user, then retrieve model from Session var checkResult = await CheckUserRegisteredOkAsync(); if (checkResult != null) { return(checkResult); } var stashedReturnViewModel = UnstashModel <ReturnViewModel>(); #endregion if (stashedReturnViewModel == null) { return(SessionExpiredView()); } postedReturnViewModel.ReportInfo = stashedReturnViewModel.ReportInfo; ExcludeBlankFieldsFromModelState(postedReturnViewModel); ConfirmPayBandsAddUpToOneHundred(postedReturnViewModel); ValidateBonusIntegrity(postedReturnViewModel); #region Keep draft file locked to this user await _SubmissionPresenter.KeepDraftFileLockedToUserAsync(postedReturnViewModel, CurrentUser.UserId); if (!postedReturnViewModel.ReportInfo.Draft.HasDraftBeenModifiedDuringThisSession) { postedReturnViewModel.ReportInfo.Draft.HasDraftBeenModifiedDuringThisSession = IsEnterCalculationsModified(postedReturnViewModel, stashedReturnViewModel); } if (!stashedReturnViewModel.ReportInfo.Draft.IsUserAllowedAccess) { this.CleanModelErrors <ReturnViewModel>(); return(View("CustomError", WebService.ErrorViewModelFactory.Create(3040))); } #endregion if (!ModelState.IsValid) { this.CleanModelErrors <ReturnViewModel>(); return(View("EnterCalculations", postedReturnViewModel)); } StashModel(postedReturnViewModel); var actionUrl = returnUrl.EqualsI("CheckData") ? "CheckData" : postedReturnViewModel.SectorType == SectorTypes.Public ? "OrganisationSize" : "PersonResponsible"; return(RedirectToAction(actionUrl)); }
private void ValidateBonusIntegrity(ReturnViewModel postedReturnViewModel) { // ensure that bonus differences do not exceed 100% when females have a bonus if (postedReturnViewModel.FemaleMedianBonusPayPercent > 0) { if (postedReturnViewModel.DiffMeanBonusPercent > 100) { AddModelError(2130, nameof(postedReturnViewModel.DiffMeanBonusPercent)); } if (postedReturnViewModel.DiffMedianBonusPercent > 100) { AddModelError(2130, nameof(postedReturnViewModel.DiffMedianBonusPercent)); } } // prevents entering a difference when male bonus percent is 0 if (postedReturnViewModel.MaleMedianBonusPayPercent == 0) { if (postedReturnViewModel.DiffMeanBonusPercent.HasValue) { AddModelError(2131, nameof(postedReturnViewModel.DiffMeanBonusPercent)); } if (postedReturnViewModel.DiffMedianBonusPercent.HasValue) { AddModelError(2131, nameof(postedReturnViewModel.DiffMedianBonusPercent)); } } }
public async Task <IActionResult> LateReason(ReturnViewModel postedReturnViewModel) { #region Check user, then retrieve model from Session var checkResult = await CheckUserRegisteredOkAsync(); if (checkResult != null) { return(checkResult); } var stashedReturnViewModel = UnstashModel <ReturnViewModel>(); #endregion if (stashedReturnViewModel == null) { return(SessionExpiredView()); } postedReturnViewModel.ReportInfo.Draft = stashedReturnViewModel.ReportInfo.Draft; postedReturnViewModel.LateReason = postedReturnViewModel.LateReason?.Trim(); ModelState.Include(nameof(postedReturnViewModel.LateReason), nameof(postedReturnViewModel.EHRCResponse)); return(!ModelState.IsValid ? View(postedReturnViewModel) : await CheckData(postedReturnViewModel)); }
public ActionResult ReturnVehicle(ReturnViewModel returnView) { if (!ModelState.IsValid) { return(View("ReturnVehicleForm", returnView)); } DBConnection aConnection = new DBConnection(); ReserveGrabber grabber = aConnection.ReserveChecker(returnView); if (grabber.Result) { if (!grabber.Returned) { Reservation reservation = aConnection.GetReserveInfo(grabber.ID); Session["Reservation"] = reservation; } else { TempData["Returned"] = "Reservation has been paid and closed."; return(RedirectToAction("ReturnVehicleForm")); } } else { TempData["NoReserve"] = "Reservation does not exist"; return(RedirectToAction("ReturnVehicleForm")); } ViewBag.User = returnView; return(View()); }
public ActionResult Create(int?id) { var userName = System.Web.HttpContext.Current.User.Identity.Name; var user = _systemService.GetUserAndRole(0, userName); if (user == null) { return(RedirectToAction("Index", "Login")); } if (user.StockOutR == 0) { return(RedirectToAction("Index", "Home")); } var model = new ReturnViewModel { UserLogin = user, Stores = new SelectList(_systemService.StoreList(), "Id", "Name"), Projects = new SelectList(_systemService.ProjectList(), "Id", "vProjectID"), ProjectNames = new SelectList(_systemService.ProjectList(), "Id", "vProjectName") }; return(View(model)); }
public ReturnViewModel Update(ScheduleViewModel model) { var result = new ReturnViewModel(); var entity = _repository.GetById(model.ScheduleId); if (entity == null) { result.Message = "schedule not found"; return(result); } entity.AvailableOn = model.AvailableOn.Date; entity.Remark = model.Remark; entity.CategoryId = model.CategoryId; entity.ModifiedOn = DateTime.Now; try { _repository.Update(entity); } catch (Exception ex) { result.Message = ex.Message; return(result); } result.IsSuccess = true; return(result); }
private void ReturnViewModelMapCommonAsserts(ReturnViewModel result) { result.ReturnId.Should().Be(mapperTestId); result.Quarter.Should().Be(mapperTestQuarter.Q.ToString()); result.Year.Should().Be(mapperTestYear.ToString()); result.Period.Should().Be(mapperTestPeriod); }
public ReturnViewModel Patch(long id, string name, int price, string desc) { var result = new ReturnViewModel(); if (string.IsNullOrEmpty(name)) { result.Message = "product name is null or empty"; return(result); } var entity = _repository.GetById(id); if (entity == null) { result.Message = "product not found"; return(result); } entity.Name = name; entity.Description = desc; entity.Price = price; entity.ModifiedOn = DateTime.Now; try { _repository.Update(entity); } catch (Exception ex) { result.Message = ex.Message; return(result); } result.IsSuccess = true; return(result); }
public ReturnViewModel Create(ProductBaseModel model) { var result = new ReturnViewModel(); if (!model.CategoryId.HasValue) { result.Message = "CategoryId is null ?"; return(result); } var entity = new Product { Name = model.ProductName, Description = model.Description, Price = model.Price, Seq = model.Seq, CategoryId = model.CategoryId.Value, AddedOn = DateTime.Now.Date, }; try { _repository.Create(entity); } catch (Exception ex) { result.Message = ex.Message; return(result); } result.Message = entity.Id.ToString(); result.IsSuccess = true; return(result); }
DraftFileBusinessLogic_GetDraftIfAvailable_When_Json_Has_Data_And_Not_Bak_File_Return_DraftAsync() { // Arrange var trevorUserId = testUserId; var systemFileRepository = new SystemFileRepository(new StorageOptions()); testDraftFileBusinessLogic = new DraftFileBusinessLogic(null, systemFileRepository); var returnViewModelThatTrevorWillSendFirst = new ReturnViewModel { DiffMedianBonusPercent = 11.1m }; var emptyDraftLockedToTrevor = await testDraftFileBusinessLogic.GetExistingOrNewAsync(testOrganisationId, testSnapshotYear, trevorUserId); var draftWithFirstLoadOfData = await testDraftFileBusinessLogic.UpdateAsync( returnViewModelThatTrevorWillSendFirst, emptyDraftLockedToTrevor, trevorUserId); await testDraftFileBusinessLogic.CommitDraftAsync(draftWithFirstLoadOfData); // Act var availableDraft = await testDraftFileBusinessLogic.GetDraftIfAvailableAsync(testOrganisationId, testSnapshotYear); // Assert Assert.NotNull(availableDraft, "Json has data and there isn't a bak file, this is a consistent state, so a draft is available"); // Cleanup await testDraftFileBusinessLogic.DiscardDraftAsync(availableDraft); }
DraftFileBusinessLogic_GetDraftIfAvailable_When_Json_Has_Data_And_Bak_File_Empty_Return_NullAsync() { // Arrange var oliviaUserId = testUserId; var systemFileRepository = new SystemFileRepository(new StorageOptions()); testDraftFileBusinessLogic = new DraftFileBusinessLogic(null, systemFileRepository); var returnViewModelThatOliviaWillSendFirst = new ReturnViewModel { DiffMedianBonusPercent = 11.1m }; var emptyDraftLockedToOlivia = await testDraftFileBusinessLogic.GetExistingOrNewAsync(testOrganisationId, testSnapshotYear, oliviaUserId); await testDraftFileBusinessLogic.UpdateAsync(returnViewModelThatOliviaWillSendFirst, emptyDraftLockedToOlivia, oliviaUserId); // Act var availableDraft = await testDraftFileBusinessLogic.GetDraftIfAvailableAsync(testOrganisationId, testSnapshotYear); // Assert Assert.Null( availableDraft, "Both files exist, as it is an inconsistent state (bak shouldn't be there if the process completed correctly), we used the backed up file as the reference because it's the most 'correct'. Bak file was empty, therefore null was expected"); // Cleanup await testDraftFileBusinessLogic.DiscardDraftAsync(emptyDraftLockedToOlivia); }
private void ConfirmPayBandsAddUpToOneHundred(ReturnViewModel postedReturnViewModel) { if (!postedReturnViewModel.MaleUpperQuartilePayBand.IsNull() || !postedReturnViewModel.FemaleUpperQuartilePayBand.IsNull()) { if (postedReturnViewModel.MaleUpperQuartilePayBand + postedReturnViewModel.FemaleUpperQuartilePayBand != 100) { AddModelError(2052, nameof(postedReturnViewModel.FemaleUpperQuartilePayBand)); } } if (!postedReturnViewModel.MaleUpperPayBand.IsNull() || !postedReturnViewModel.FemaleUpperPayBand.IsNull()) { if (postedReturnViewModel.MaleUpperPayBand + postedReturnViewModel.FemaleUpperPayBand != 100) { AddModelError(2052, nameof(postedReturnViewModel.FemaleUpperPayBand)); } } if (!postedReturnViewModel.MaleMiddlePayBand.IsNull() || !postedReturnViewModel.FemaleMiddlePayBand.IsNull()) { if (postedReturnViewModel.MaleMiddlePayBand + postedReturnViewModel.FemaleMiddlePayBand != 100) { AddModelError(2052, nameof(postedReturnViewModel.FemaleMiddlePayBand)); } } if (!postedReturnViewModel.MaleLowerPayBand.IsNull() || !postedReturnViewModel.FemaleLowerPayBand.IsNull()) { if (postedReturnViewModel.MaleLowerPayBand + postedReturnViewModel.FemaleLowerPayBand != 100) { AddModelError(2052, nameof(postedReturnViewModel.FemaleLowerPayBand)); } } }
public ReturnViewModel Update(SettingViewModel model) { var result = new ReturnViewModel(); var entity = _repository.GetById(model.SettingId); if (entity == null) { result.Message = "setting not found"; return(result); } entity.StopHourOn = model.StopHourOn; entity.Announcement = model.Announcement; entity.ModifiedOn = DateTime.Now; try { _repository.Update(entity); } catch (Exception ex) { result.Message = ex.Message; return(result); } result.IsSuccess = true; return(result); }
public ReturnViewModel Create(CategoryBaseModel model) { var result = new ReturnViewModel(); var entity = new Category { Name = model.CategoryName, Description = model.Description, Address = model.Address, PhoneNumber = model.PhoneNumber, Url = model.Url, Image = model.Image, AddedOn = DateTime.Now, }; try { _repository.Create(entity); } catch (Exception ex) { result.Message = ex.Message; return(result); } result.IsSuccess = true; result.Message = entity.Id.ToString(); return(result); }
public ReturnViewModel Update(CategoryViewModel model) { var result = new ReturnViewModel(); var entity = _repository.GetById(model.CategoryId); if (entity == null) { result.Message = "category not found"; return(result); } entity.Name = model.CategoryName; entity.Description = model.Description; entity.Seq = model.Seq; entity.PhoneNumber = model.PhoneNumber; entity.Address = model.Address; entity.Url = model.Url; entity.Image = model.Image; entity.ModifiedOn = DateTime.Now; try { _repository.Update(entity); } catch (Exception ex) { result.Message = ex.Message; return(result); } result.IsSuccess = true; return(result); }
public async Task <IActionResult> Return(int id, [Bind("Id, DataDo, Pozycja")] ReturnViewModel historia) { await _historiaService.PutHistoriaAsync(historia.Pozycja.PozycjaId, historia.DataDo); return(RedirectToAction(nameof(Index), "Pozycje")); }
private ReturnViewModel LoadDraftReturnAsReturnViewModel(Draft resultingDraft) { DraftReturn draftReturnFromDatabase = GetDraftReturnFromDatabase(resultingDraft.OrganisationId, resultingDraft.SnapshotYear); ReturnViewModel returnViewModel = CastDatabaseDraftReturnToReturnViewModel(draftReturnFromDatabase); return(returnViewModel); }
public ReturnViewModel DeleteTodayListByUser(long userId) { var result = new ReturnViewModel(); var today = DateTime.Now.Date; var entities = _repository.Find(x => x.UserId == userId && x.AddedOn.Date == today); if (entities == null || !entities.Any()) { result.Message = "user's order not found"; return(result); } try { foreach (var entity in entities) { _repository.Delete(entity); } } catch (Exception ex) { result.Message = ex.Message; return(result); } result.IsSuccess = true; return(result); }
public ActionResult EmployerWebsite/*GPGInfoLink*/ (ReturnViewModel model) { //Ensure user has completed the registration process User currentUser; var checkResult = CheckUserRegisteredOk(out currentUser); if (checkResult != null) { return(checkResult); } if (model.SectorType == SectorTypes.Public) { ModelState.Remove(nameof(model.FirstName)); ModelState.Remove(nameof(model.LastName)); ModelState.Remove(nameof(model.JobTitle)); } if (!ModelState.IsValid) { this.CleanModelErrors <ReturnViewModel>(); return(View(model)); } this.StashModel(model); return(RedirectToAction("CheckData")); }
public async Task <IActionResult> CancelCheckData(ReturnViewModel postedReturnViewModel) { #region Check user, then retrieve model from Session IActionResult checkResult = CheckUserRegisteredOk(out User currentUser); if (checkResult != null) { return(checkResult); } var stashedReturnViewModel = this.UnstashModel <ReturnViewModel>(); #endregion if (stashedReturnViewModel == null) { return(SessionExpiredView()); } postedReturnViewModel.ReportInfo.Draft = stashedReturnViewModel.ReportInfo.Draft; postedReturnViewModel.OriginatingAction = "CheckData"; bool hasDraftChanged = postedReturnViewModel.ReportInfo.Draft.HasDraftBeenModifiedDuringThisSession; return(await PresentUserTheOptionOfSaveDraftOrIgnoreAsync(postedReturnViewModel, hasDraftChanged)); }
public void HasDraftWithContent_When_ReturnViewModelContent_Is_Not_Null_Returns_True() { // Arrange var returnViewModelContentUnderDraft = new ReturnViewModel(); var testReturnViewModel = new ReturnViewModel { ReportInfo = new ReportInfoModel { Draft = new Draft(default, default)
public virtual async Task <ActionResult> Index(ReturnViewModel viewModel) { using (var client = apiClient()) { await client.SendAsync(User.GetAccessToken(), new SubmitReturn(viewModel.ReturnId)); } return(await Task.Run <ActionResult>(() => AatfRedirect.SubmittedReturn(viewModel.ReturnId))); }
public async Task <IActionResult> PersonResponsible(ReturnViewModel postedReturnViewModel, string returnUrl = null) { #region Check user, then retrieve model from Session var checkResult = await CheckUserRegisteredOkAsync(); if (checkResult != null) { return(checkResult); } var stashedReturnViewModel = UnstashModel <ReturnViewModel>(); #endregion if (stashedReturnViewModel == null) { return(SessionExpiredView()); } postedReturnViewModel.ReportInfo = stashedReturnViewModel.ReportInfo; ExcludeBlankFieldsFromModelState(postedReturnViewModel); ModelState.Include( nameof(postedReturnViewModel.FirstName), nameof(postedReturnViewModel.LastName), nameof(postedReturnViewModel.JobTitle)); #region Keep draft file locked to this user await _SubmissionPresenter.KeepDraftFileLockedToUserAsync(postedReturnViewModel, CurrentUser.UserId); if (!postedReturnViewModel.ReportInfo.Draft.HasDraftBeenModifiedDuringThisSession) { postedReturnViewModel.ReportInfo.Draft.HasDraftBeenModifiedDuringThisSession = IsPersonResponsibleModified(postedReturnViewModel, stashedReturnViewModel); } if (!stashedReturnViewModel.ReportInfo.Draft.IsUserAllowedAccess) { this.CleanModelErrors <ReturnViewModel>(); return(View("CustomError", WebService.ErrorViewModelFactory.Create(3040))); } #endregion if (!ModelState.IsValid) { this.CleanModelErrors <ReturnViewModel>(); return(View("PersonResponsible", postedReturnViewModel)); } StashModel(postedReturnViewModel); return(RedirectToAction(returnUrl.EqualsI("CheckData") ? "CheckData" : "OrganisationSize")); }
private static bool IsPersonResponsibleModified(ReturnViewModel postedReturnViewModel, ReturnViewModel stashedReturnViewModel) { bool hasFirstNameChanged = stashedReturnViewModel != null && postedReturnViewModel.FirstName != stashedReturnViewModel.FirstName; bool hasLastNameChanged = stashedReturnViewModel != null && postedReturnViewModel.LastName != stashedReturnViewModel.LastName; bool hasJobTitleChanged = stashedReturnViewModel != null && postedReturnViewModel.JobTitle != stashedReturnViewModel.JobTitle; return(hasFirstNameChanged || hasLastNameChanged || hasJobTitleChanged); }
public ActionResult Create(int? id) { var userName = System.Web.HttpContext.Current.User.Identity.Name; var user = _systemService.GetUserAndRole(0, userName); if (user == null) { return RedirectToAction("Index", "Login"); } if (user.StockOutR == 0) { return RedirectToAction("Index", "Home"); } var model = new ReturnViewModel { UserLogin = user, Stores = new SelectList(_systemService.StoreList(), "Id", "Name"), Projects = new SelectList(_systemService.ProjectList(), "Id", "vProjectID"), ProjectNames = new SelectList(_systemService.ProjectList(), "Id", "vProjectName") }; return View(model); }
public ActionResult LoadDataDetailList(string id, string enable) { var detailList = _service.ListConditionDetail(id, enable); var model = new ReturnViewModel { StockReturnDetailList = detailList, TotalRecords = detailList.Count() }; return PartialView("_ReturnDetailPartial", model); }
public ActionResult LoadDataList(int page, int size, int store, int project, int stockType, string stockCode, string stockName, string srv, string fd, string td, string enable) { var userName = System.Web.HttpContext.Current.User.Identity.Name; var totalRecord = _service.ListConditionCount(page, size, store, project, stockType, stockCode, stockName, srv, fd, td, enable); var totalTemp = Convert.ToDecimal(totalRecord) / Convert.ToDecimal(size); var totalPages = Convert.ToInt32(Math.Ceiling(totalTemp)); var model = new ReturnViewModel { UserLogin = _systemService.GetUserAndRole(0, userName), ReturnStockList = _service.ListCondition(page, size, store, project, stockType, stockCode, stockName, srv, fd, td, enable), TotalRecords = Convert.ToInt32(totalRecord), TotalPages = totalPages, CurrentPage = page, PageSize = size }; return PartialView("_ReturnPartial", model); }