//public ActionResult Promote(BusinessProcessState st, int PaymentRequestID, int transporterID) //{ // _businessProcessService.PromotWorkflow(st); // var transporterChequeObj = // _transporterChequeService.Get(t => t.TransporterPaymentRequestID == PaymentRequestID).FirstOrDefault(); // if (transporterChequeObj != null) // { // if (st.StateID == (int) Cats.Models.Constant.StateTemplate.ChequeApproved) // { // transporterChequeObj.AppovedBy = UserAccountHelper.GetUser(User.Identity.Name).UserProfileID; // transporterChequeObj.AppovedDate = DateTime.Now; // transporterChequeObj.Status = (int)Cats.Models.Constant.ChequeStatus.ChequeApproved; // _transporterChequeService.EditTransporterCheque(transporterChequeObj); // } // if (st.StateID == (int)Cats.Models.Constant.StateTemplate.ChequeCollected) // { // transporterChequeObj.Status = (int)Cats.Models.Constant.ChequeStatus.ChequeCollected; // _transporterChequeService.EditTransporterCheque(transporterChequeObj); // } // } // return RedirectToAction("PaymentRequests", "ValidatedPaymentRequest", new {Area = "Finance", transporterID}); //} public ActionResult TransportOrderDetail(int transportOrderID) { var transportOrder = _transportOrderService.Get(t => t.TransportOrderID == transportOrderID, null, "TransportOrderDetails.FDP,TransportOrderDetails.FDP.AdminUnit,TransportOrderDetails.Commodity,TransportOrderDetails.Hub,TransportOrderDetails.ReliefRequisition").FirstOrDefault(); var datePref = UserAccountHelper.GetUser(User.Identity.Name).DatePreference; var statuses = _workflowStatusService.GetStatus(WORKFLOW.TRANSPORT_ORDER); var transportOrderViewModel = TransportOrderViewModelBinder.BindTransportOrderViewModel(transportOrder, datePref, statuses); ViewData["Transport.order.detail.ViewModel"] = transportOrder == null ? null : GetDetail(transportOrder.TransportOrderDetails); return(View(transportOrderViewModel)); }
public ActionResult LoadCheque(int transporterId, string refNo) { var user = UserAccountHelper.GetUser(User.Identity.Name); var approvedPaymentRequests = _transporterPaymentRequestService.Get(t => t.BusinessProcess.CurrentState.BaseStateTemplate.StateNo == 3 && t.TransportOrder.TransporterID == transporterId); if (refNo != "") { approvedPaymentRequests = _transporterPaymentRequestService.Get(t => t.BusinessProcess.CurrentState.BaseStateTemplate.StateNo == 3 && t.TransportOrder.TransporterID == transporterId && t.ReferenceNo == refNo); } //var transporterChequeObj = _transporterChequeService.Get(t => t.TransporterPaymentRequestID == paymentRequestID, null, "UserProfile").FirstOrDefault(); var transporterChequeViewModel = new Models.TransporterChequeViewModel(); foreach (var approvedPaymentRequest in approvedPaymentRequests) { var request = approvedPaymentRequest; var dispatch = _dispatchService.Get(t => t.DispatchID == request.Delivery.DispatchID, null, "Hub, FDP").FirstOrDefault(); var bidId = _bidWinnerService.FindBy(b => b.Bid.BidNumber == dispatch.BidNumber).Select(d => d.BidID).FirstOrDefault(); var firstOrDefault = _transportOrderDetailService.Get(t => t.SourceWarehouseID == dispatch.HubID && t.FdpID == dispatch.FDPID && t.TransportOrder.TransporterID == request.TransportOrder.TransporterID && t.BidID == bidId).FirstOrDefault(); //var firstOrDefault = _bidWinnerService.Get(t => t.SourceID == dispatch.HubID && t.DestinationID == dispatch.FDPID // && t.TransporterID == request.TransportOrder.TransporterID && t.Bid.BidNumber == dispatch.BidNumber).FirstOrDefault(); var tarrif = (decimal)0.00; var deliveryDetail = request.Delivery.DeliveryDetails.FirstOrDefault() ?? new DeliveryDetail(); if (request.LabourCost == null) { request.LabourCost = (decimal)0.00; } if (request.RejectedAmount == null) { request.RejectedAmount = (decimal)0.00; } if (firstOrDefault != null) { tarrif = (decimal)firstOrDefault.TariffPerQtl; } transporterChequeViewModel.Transporter = request.TransportOrder.Transporter.Name; transporterChequeViewModel.PaymentRequestsList = transporterChequeViewModel.PaymentRequestsList + " [" + approvedPaymentRequest.ReferenceNo + "] "; transporterChequeViewModel.Amount = transporterChequeViewModel.Amount + (decimal) (approvedPaymentRequest.ShortageBirr != null ? (deliveryDetail.ReceivedQuantity.ToQuintal() * tarrif) - approvedPaymentRequest.ShortageBirr + approvedPaymentRequest.LabourCost - approvedPaymentRequest.RejectedAmount : (deliveryDetail.ReceivedQuantity.ToQuintal() * tarrif) + approvedPaymentRequest.LabourCost - approvedPaymentRequest.RejectedAmount); } transporterChequeViewModel.PreparedByID = user.UserProfileID; transporterChequeViewModel.PreparedBy = user.FullName; return(Json(transporterChequeViewModel, JsonRequestBehavior.AllowGet)); }
protected void Application_AuthenticateRequest(object sender, EventArgs e) { HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie != null && authCookie.Value != "") { FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); var identity = new UserIdentity(UserAccountHelper.GetUser(ticket.Name)); var principal = new UserPrincipal(identity); HttpContext.Current.User = principal; } }
public ActionResult ApproveChequeInfo(int transporterChequeID) { var user = UserAccountHelper.GetUser(User.Identity.Name); var transporterChequeObj = _transporterChequeService.FindById(transporterChequeID); transporterChequeObj.AppovedBy = user.UserProfileID; transporterChequeObj.AppovedDate = DateTime.Now; transporterChequeObj.Status = 2; _transporterChequeService.EditTransporterCheque(transporterChequeObj); //var transporterChequeViewModel = BindTransporterChequeViewModel(transporterChequeObj); return(Json(transporterChequeID, JsonRequestBehavior.AllowGet)); }
public EquipmentTypeController(DbAppContext context, IHttpContextAccessor httpContextAccessor) { _context = context; // set context data User user = UserAccountHelper.GetUser(context, httpContextAccessor.HttpContext); _context.SmUserId = user.SmUserId; _context.DirectoryName = user.SmAuthorizationDirectory; _context.SmUserGuid = user.UserGuid; _context.SmBusinessGuid = user.BusinessGuid; }
public FileResult Print(int id) { var reportPath = Server.MapPath("~/Report/Procurment/TransportOrder.rdlc"); var Data = _transportOrderService.GeTransportOrderRpt(id); var datePref = UserAccountHelper.GetUser(User.Identity.Name).DatePreference; var reportData = vwTransportOrderViewModelBinder.BindListvwTransportOrderViewModel(Data, datePref); var dataSourceName = "TransportOrders"; var result = ReportHelper.PrintReport(reportPath, reportData, dataSourceName); return(File(result.RenderBytes, result.MimeType)); }
public ActionResult Edit(HRD hrd) { var userid = UserAccountHelper.GetUser(HttpContext.User.Identity.Name).UserProfileID; hrd.CreatedBY = userid; if (ModelState.IsValid) { _hrdService.EditHRD(hrd); return(RedirectToAction("Index")); } return(View(hrd)); }
public ProvincialRateTypeController(DbAppContext context, IConfiguration configuration, IHttpContextAccessor httpContextAccessor) { _context = context; _configuration = configuration; // set context data User user = UserAccountHelper.GetUser(context, httpContextAccessor.HttpContext); _context.SmUserId = user.SmUserId; _context.DirectoryName = user.SmAuthorizationDirectory; _context.SmUserGuid = user.UserGuid; _context.SmBusinessGuid = user.BusinessGuid; }
public RentalRequestController(DbAppContext context, IConfiguration configuration, IHttpContextAccessor httpContextAccessor, ILoggerFactory loggerFactory) { _context = context; _configuration = configuration; _httpContext = httpContextAccessor.HttpContext; // set context data User user = UserAccountHelper.GetUser(context, httpContextAccessor.HttpContext); _context.SmUserId = user.SmUserId; _context.DirectoryName = user.SmAuthorizationDirectory; _context.SmUserGuid = user.UserGuid; _context.SmBusinessGuid = user.BusinessGuid; }
// // GET: /Regional/Home/ public ActionResult Index() { var currentUser = UserAccountHelper.GetUser(HttpContext.User.Identity.Name); if (!currentUser.RegionalUser || currentUser.RegionID == null) { ModelState.AddModelError("Errors", @"You are not assigned to any region"); } ViewBag.RegionID = currentUser.RegionID; ViewBag.RegionName = currentUser.RegionID != null?_adminUnitService.FindById(currentUser.RegionID ?? 0).Name : "[region not set for user]"; return(View()); }
public VersionController(DbAppContext context, IConfiguration configuration, IHttpContextAccessor httpContextAccessor, IHostingEnvironment env) { _context = context; _configuration = configuration; _env = env; // set context data User user = UserAccountHelper.GetUser(context, httpContextAccessor.HttpContext); _context.SmUserId = user.SmUserId; _context.DirectoryName = user.SmAuthorizationDirectory; _context.SmUserGuid = user.UserGuid; _context.SmBusinessGuid = user.BusinessGuid; }
public ActionResult EditUserRoles(string UserName) { //var roles = new string[] { "EW Coordinator", "EW-Experts" }; //userService.AddRoleSample("Rahel", "Early Warning", roles); var user = UserAccountHelper.GetUser(HttpContext.User.Identity.Name); var model = new UserViewModel(); model.UserName = UserName; model.Email = user.Email; List <Application> Applications = _userService.GetUserPermissions(UserName); ViewBag.hubs = new SelectList(_hubService.GetAllHub(), "HubID", "Name"); model.Applications = Applications; return(View(model)); }
public ActionResult ChangePassword2(FormCollection values) { var userid = UserAccountHelper.GetUser(HttpContext.User.Identity.Name).UserProfileID; var oldpassword = _userService.HashPassword(values["OldPassword"]); if (ModelState.IsValid) { bool changePasswordSucceeded; if (_userService.GetUserDetail(userid).Password == oldpassword) { try { changePasswordSucceeded = _userService.ChangePassword(userid, values["NewPassword"]); } catch (Exception e) { changePasswordSucceeded = false; //ModelState.AddModelError("Errors", e.Message); } if (changePasswordSucceeded) { TempData["error"] = "Success, Password Successfully Changed. Please logout and login with the new credential"; } //return RedirectToAction("ChangePasswordSuccess"); else { TempData["error"] = "Errors, The new password is invalid."; } } else { TempData["error"] = "Errors, The current password is incorrect "; } } var urlReferrer = this.Request.UrlReferrer; if (urlReferrer == null) { Session.Clear(); FormsAuthentication.SignOut(); return(RedirectToAction("Index", "Home")); } var url = urlReferrer.AbsolutePath; ModelState.AddModelError("Sucess", @"Password Successfully Changed."); return(Redirect(url)); }
public CurrentUserController(DbAppContext context, IConfiguration configuration, IHttpContextAccessor httpContextAccessor, ILoggerFactory loggerFactory, IHostingEnvironment env) { _context = context; _configuration = configuration; _logger = loggerFactory.CreateLogger(typeof(CurrentUserController)); _env = env; _httpContext = httpContextAccessor.HttpContext; // set context data User user = UserAccountHelper.GetUser(context, _httpContext); _context.SmUserId = user.SmUserId; _context.DirectoryName = user.SmAuthorizationDirectory; _context.SmUserGuid = user.UserGuid; _context.SmBusinessGuid = user.BusinessGuid; }
public JsonResult SavePreference([DataSourceRequest] DataSourceRequest request, List <int> selectedDashboardIDs) { var userID = UserAccountHelper.GetUser(HttpContext.User.Identity.Name).UserProfileID; var userDashboardPreferences = _userDashboardPreferenceService.Get(t => t.UserID == userID).OrderBy(m => m.OrderNo); var selectedDashboardWidgets = userDashboardPreferences.Select(userDashboardPreference => _dashboardWidgetService.FindById(userDashboardPreference.DashboardWidgetID)).ToList(); var selectedDashboardWidgetIDs = selectedDashboardWidgets.Select(selectedDashboardWidget => selectedDashboardWidget.DashboardWidgetID).ToList(); //Create the newly selected dashboards in user preference var order = 1; foreach (var selectedDashboardID in selectedDashboardIDs) { if (!selectedDashboardWidgetIDs.Contains(selectedDashboardID)) { var userDashboardPreference = new UserDashboardPreference { DashboardWidgetID = selectedDashboardID, UserID = userID, OrderNo = order }; _userDashboardPreferenceService.AddUserDashboardPreference(userDashboardPreference); } order++; } //Delete the removed dashboards from the user preference foreach (var userDashboardPreferenceObj in selectedDashboardWidgetIDs.Where(selectedDashboardWidgetID => !selectedDashboardIDs.Contains(selectedDashboardWidgetID)).Select(id => _userDashboardPreferenceService.Get( t => t.DashboardWidgetID == id && t.UserID == userID).FirstOrDefault())) { _userDashboardPreferenceService.DeleteUserDashboardPreference(userDashboardPreferenceObj); } //Edit the selected dashboards order var orderNo = 1; foreach (var userDashboardPreferenceObj in selectedDashboardIDs.Select(id => _userDashboardPreferenceService.Get( t => t.DashboardWidgetID == id && t.UserID == userID).FirstOrDefault())) { userDashboardPreferenceObj.OrderNo = orderNo; _userDashboardPreferenceService.EditUserDashboardPreference(userDashboardPreferenceObj); orderNo++; } ModelState.AddModelError("Success", @"Preference Saved."); return(Json(true, JsonRequestBehavior.AllowGet)); }
public ActionResult Index() { UserInfo currentUser = UserAccountHelper.GetUser(HttpContext.User.Identity.Name); ViewBag.RegionName = currentUser.RegionID != null?_adminUnitService.FindById(currentUser.RegionID ?? 0).Name : ""; var hrd = _hrdService.FindBy(m => m.Status == 3).FirstOrDefault(); if (hrd == null) { return(HttpNotFound()); } var summary = GetHRDSummary(hrd.HRDID); return(View(summary)); }
private DeliveryViewModel CreateGoodsReceivingNote(Cats.Models.Hubs.Dispatch dispatch) { if (dispatch == null) { return(new DeliveryViewModel()); } var delivery = new DeliveryViewModel(); delivery.DeliveryDate = DateTime.Today; delivery.DispatchID = dispatch.DispatchID; delivery.DeliveryDate = DateTime.Today; delivery.DocumentReceivedBy = UserAccountHelper.GetUser(User.Identity.Name).UserProfileID; delivery.DocumentReceivedDate = DateTime.Today; delivery.DeliveryID = Guid.NewGuid(); //delivery.DonorID=dispatch. delivery.DriverName = dispatch.DriverName; delivery.FDPID = dispatch.FDPID.Value; delivery.HubID = dispatch.HubID; delivery.TransporterID = dispatch.TransporterID; delivery.InvoiceNo = dispatch.GIN; delivery.PlateNoPrimary = dispatch.PlateNo_Prime; delivery.PlateNoTrailler = dispatch.PlateNo_Trailer; delivery.RequisitionNo = dispatch.RequisitionNo; delivery.FDP = dispatch.FDP.Name; delivery.Region = dispatch.FDP.AdminUnit.AdminUnit2.AdminUnit2.Name; delivery.Zone = dispatch.FDP.AdminUnit.AdminUnit2.Name; delivery.Woreda = dispatch.FDP.AdminUnit.Name; delivery.Hub = dispatch.Hub.Name; delivery.Transporter = dispatch.Transporter.Name; //foreach (var dispatchDetail in dispatch.DispatchDetails) //{ // var deliveryDetail = new DistributionDetail(); // deliveryDetail.DistributionID = distribution.DistributionID; // deliveryDetail.DistributionDetailID = Guid.NewGuid(); // deliveryDetail.CommodityID = dispatchDetail.CommodityID; // deliveryDetail.ReceivedQuantity = 0; // deliveryDetail.SentQuantity = dispatchDetail.RequestedQuantityInMT; // deliveryDetail.UnitID = dispatchDetail.UnitID; //} return(delivery); }
public ActionResult Edit(UserPreferenceEditModel model) { if (ModelState.IsValid) { var user = _userAccountService.GetUserDetail(HttpContext.User.Identity.Name); var users = UserAccountHelper.GetUser(HttpContext.User.Identity.Name); user.DefaultTheme = model.ThemePreference; user.DatePreference = model.DateFormatPreference; user.Keyboard = model.KeyboardLanguage; user.LanguageCode = model.Languages; user.PreferedWeightMeasurment = model.WeightPrefernce; // Edit user preference _userAccountService.UpdateUser(user); TempData["PreferenceUpdateSuccessMsg"] = "Success: General preference updated"; var userInfo = new UserInfo { UserName = user.UserName, FirstName = user.FirstName, LastName = user.LastName, ActiveInd = user.ActiveInd, CaseTeam = user.CaseTeam, DatePreference = user.DatePreference, DefaultTheme = user.DefaultTheme, Email = user.Email, FailedAttempts = user.FailedAttempts, GrandFatherName = user.GrandFatherName, Keyboard = user.Keyboard, LanguageCode = user.LanguageCode, LockedInInd = user.LockedInInd, LogOutDate = user.LogOutDate, LogginDate = user.LogginDate, NumberOfLogins = user.NumberOfLogins, PreferedWeightMeasurment = user.PreferedWeightMeasurment.Trim() }; Session["USER_INFO"] = userInfo; } else { TempData["PreferenceUpdateErrorMsg"] = "Error: General preference not updated"; } return(RedirectToAction("Preference", "Home")); }
public ActionResult Create(Ration ration) { if (ration != null && ModelState.IsValid) { try { ration.CreatedBy = UserAccountHelper.GetUser(HttpContext.User.Identity.Name).UserProfileID; ration.CreatedDate = DateTime.Today; _rationService.AddRation(ration); return(RedirectToAction("Index")); } catch (Exception ex) { var log = new Logger(); log.LogAllErrorsMesseges(ex, _log); ModelState.AddModelError("Errors", ex.Message); } } return(PartialView("_Create", ration)); }
public ActionResult ChangePasswordAjax(FormCollection values) { var userid = UserAccountHelper.GetUser(HttpContext.User.Identity.Name).UserProfileID; var oldpassword = _userService.HashPassword(values["OldPassword"]); //TempData["error"] = "Unknown Error"; if (ModelState.IsValid) { bool changePasswordSucceeded; if (_userService.GetUserDetail(userid).Password == oldpassword) { try { changePasswordSucceeded = _userService.ChangePassword(userid, values["NewPassword"]); } catch (Exception e) { changePasswordSucceeded = false; //ModelState.AddModelError("Errors", e.Message); } if (changePasswordSucceeded) { TempData["success"] = "Success, Password Successfully Changed. Please logout and login with the new credential"; } //return RedirectToAction("ChangePasswordSuccess"); else { TempData["error"] = "Errors, The new password is invalid."; } } else { TempData["error"] = "Errors, The current password is incorrect "; } return(Json(TempData, JsonRequestBehavior.AllowGet)); } return(Json(TempData, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(RationViewModel rationViewModel) { if (rationViewModel != null && ModelState.IsValid) { try { var orign = _rationService.FindById(rationViewModel.RationID); orign.IsDefaultRation = rationViewModel.IsDefaultRation; orign.UpdatedBy = UserAccountHelper.GetUser(HttpContext.User.Identity.Name).UserProfileID; orign.UpdatedDate = DateTime.Today; _rationService.EditRation(orign); return(Json(new { success = true })); } catch (Exception ex) { var log = new Logger(); log.LogAllErrorsMesseges(ex, _log); ModelState.AddModelError("Errors", ex.Message); } } return(PartialView("_Edit", rationViewModel)); }
public ActionResult ChangePassword(ChangePasswordModel model) { var userid = UserAccountHelper.GetUser(HttpContext.User.Identity.Name).UserProfileID; var oldpassword = _userService.HashPassword(model.OldPassword); if (ModelState.IsValid) { bool changePasswordSucceeded; if (_userService.GetUserDetail(userid).Password == oldpassword) { try { changePasswordSucceeded = _userService.ChangePassword(userid, model.NewPassword); } catch (Exception e) { changePasswordSucceeded = false; //ModelState.AddModelError("Errors", e.Message); } if (changePasswordSucceeded) { ModelState.AddModelError("Success", @"Password Successfully Changed."); } //return RedirectToAction("ChangePasswordSuccess"); else { ModelState.AddModelError("Errors", @"The new password is invalid."); } } else { ModelState.AddModelError("Errors", @"The current password is incorrect "); } } return(View(model)); }
public virtual IActionResult RentalRequestIdRotationListIdPut([FromRoute] int id, [FromBody] HetRentalRequestRotationList item) { // not found if (item == null) { return(new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration)))); } bool exists = _context.HetRentalRequest.Any(a => a.RentalRequestId == id); // not found if (!exists) { return(new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration)))); } int?statusId = StatusHelper.GetStatusId(HetRentalRequest.StatusInProgress, "rentalRequestStatus", _context); if (statusId == null) { return(new NotFoundObjectResult(new HetsResponse("HETS-23", ErrorViewModel.GetDescription("HETS-23", _configuration)))); } // check if we have the rental request that is In Progress exists = _context.HetRentalRequest .Any(a => a.RentalRequestId == id && a.RentalRequestStatusTypeId == statusId); // rental request must be "in progress" if (!exists) { return(new BadRequestObjectResult(new HetsResponse("HETS-06", ErrorViewModel.GetDescription("HETS-06", _configuration)))); } // get rental request record HetRentalRequest request = _context.HetRentalRequest .Include(x => x.Project) .ThenInclude(x => x.District) .Include(x => x.LocalArea) .Include(x => x.HetRentalRequestRotationList) .ThenInclude(x => x.Equipment) .First(a => a.RentalRequestId == id); // get rotation list record HetRentalRequestRotationList requestRotationList = _context.HetRentalRequestRotationList .FirstOrDefault(a => a.RentalRequestRotationListId == item.RentalRequestRotationListId); // not found if (requestRotationList == null) { return(new NotFoundObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration)))); } // update rotation list record int tempEquipmentId = item.Equipment.EquipmentId; requestRotationList.ConcurrencyControlNumber = item.ConcurrencyControlNumber; requestRotationList.EquipmentId = tempEquipmentId; requestRotationList.IsForceHire = item.IsForceHire; requestRotationList.AskedDateTime = DateTime.UtcNow; requestRotationList.Note = item.Note; requestRotationList.OfferRefusalReason = item.OfferRefusalReason; requestRotationList.OfferResponse = item.OfferResponse; requestRotationList.OfferResponseDatetime = item.OfferResponseDatetime; requestRotationList.WasAsked = item.WasAsked; requestRotationList.OfferResponseNote = item.OfferResponseNote; // do we need to create or modify a Rental Agreement? if (item.IsForceHire == true || item.OfferResponse.Equals("Yes", StringComparison.InvariantCultureIgnoreCase)) { // get rental agreement record HetRentalAgreement rentalAgreement = _context.HetRentalAgreement .FirstOrDefault(a => a.RentalAgreementId == item.RentalAgreementId); // create rental agreement if it doesn't exist if (rentalAgreement == null) { // generate the rental agreement number string agreementNumber = RentalAgreementHelper.GetRentalAgreementNumber(item.Equipment, _context); // get user info - agreement city User user = UserAccountHelper.GetUser(_context, _httpContext); string agreementCity = user.AgreementCity; int?rateTypeId = StatusHelper.GetRatePeriodId(HetRatePeriodType.PeriodHourly, _context); if (rateTypeId == null) { return(new NotFoundObjectResult(new HetsResponse("HETS-24", ErrorViewModel.GetDescription("HETS-24", _configuration)))); } rentalAgreement = new HetRentalAgreement { ProjectId = request.ProjectId, DistrictId = request.Project.District.DistrictId, EquipmentId = tempEquipmentId, Number = agreementNumber, RatePeriodTypeId = (int)rateTypeId, AgreementCity = agreementCity }; // add overtime rates List <HetProvincialRateType> overtime = _context.HetProvincialRateType.AsNoTracking() .Where(x => x.Overtime) .ToList(); // agreement overtime records (default overtime flag) foreach (HetProvincialRateType rate in overtime) { // add the rate HetRentalAgreementRate newAgreementRate = new HetRentalAgreementRate { Comment = rate.Description, ComponentName = rate.RateType, Overtime = true, Active = rate.Active, IsIncludedInTotal = rate.IsIncludedInTotal, Rate = rate.Rate }; if (rentalAgreement.HetRentalAgreementRate == null) { rentalAgreement.HetRentalAgreementRate = new List <HetRentalAgreementRate>(); } rentalAgreement.HetRentalAgreementRate.Add(newAgreementRate); } _context.HetRentalAgreement.Add(rentalAgreement); } int?statusIdAgreement = StatusHelper.GetStatusId(HetRentalAgreement.StatusActive, "rentalAgreementStatus", _context); if (statusIdAgreement == null) { return(new NotFoundObjectResult(new HetsResponse("HETS-23", ErrorViewModel.GetDescription("HETS-23", _configuration)))); } // update rental agreement rentalAgreement.RentalAgreementStatusTypeId = (int)statusIdAgreement; rentalAgreement.DatedOn = DateTime.UtcNow; rentalAgreement.EstimateHours = request.ExpectedHours; rentalAgreement.EstimateStartWork = request.ExpectedStartDate; rentalAgreement.RentalRequestId = request.RentalRequestId; rentalAgreement.RentalRequestRotationListId = requestRotationList.RentalRequestRotationListId; // have to save the agreement _context.SaveChanges(); // relate the new rental agreement to the original rotation list record int tempRentalAgreementId = rentalAgreement.RentalAgreementId; requestRotationList.RentalAgreementId = tempRentalAgreementId; requestRotationList.RentalAgreement = rentalAgreement; } // can we "Complete" this rental request (if the Yes or Forced Hires = Request.EquipmentCount) int countOfYeses = 0; int equipmentRequestCount = request.EquipmentCount; foreach (HetRentalRequestRotationList rotationList in request.HetRentalRequestRotationList) { if (rotationList.OfferResponse != null && rotationList.OfferResponse.Equals("Yes", StringComparison.InvariantCultureIgnoreCase)) { countOfYeses = countOfYeses + 1; } else if (rotationList.IsForceHire != null && rotationList.IsForceHire == true) { countOfYeses = countOfYeses + 1; } } if (countOfYeses >= equipmentRequestCount) { int?statusIdComplete = StatusHelper.GetStatusId(HetRentalRequest.StatusComplete, "rentalRequestStatus", _context); if (statusIdComplete == null) { return(new NotFoundObjectResult(new HetsResponse("HETS-23", ErrorViewModel.GetDescription("HETS-23", _configuration)))); } request.RentalRequestStatusTypeId = (int)statusIdComplete; request.Status = "Complete"; request.FirstOnRotationList = null; } // 1. get the number of blocks for this equipment type // 2. set which rotation list record is currently "active" int numberOfBlocks = EquipmentHelper.GetNumberOfBlocks(item.Equipment, _configuration); RentalRequestHelper.UpdateRotationList(request, numberOfBlocks, _context); // save the changes _context.SaveChanges(); // get the scoring rules SeniorityScoringRules scoringRules = new SeniorityScoringRules(_configuration); return(new ObjectResult(new HetsResponse(RentalRequestHelper.GetRecordWithRotationList(id, scoringRules, _context)))); }
/// <summary> /// Process Authentication Request /// </summary> /// <returns></returns> protected override Task <AuthenticateResult> HandleAuthenticateAsync() { // get SiteMinder headers _logger.LogDebug("Parsing the HTTP headers for SiteMinder authentication credential"); SiteMinderAuthOptions options = new SiteMinderAuthOptions(); try { HttpContext context = Request.HttpContext; DbAppContext dbAppContext = (DbAppContext)context.RequestServices.GetService(typeof(DbAppContext)); IHostingEnvironment hostingEnv = (IHostingEnvironment)context.RequestServices.GetService(typeof(IHostingEnvironment)); UserSettings userSettings = new UserSettings(); string userId = ""; string siteMinderGuid = ""; string businessGuid = ""; string url = context.Request.GetDisplayUrl().ToLower(); _logger.LogWarning("Timestamp: {0:dd-MM-yyyy HH:mm:ss.FFFF} | Url: {1} | Remote Ip: {0}", DateTime.Now, url, context.Connection.RemoteIpAddress.ToString()); // ******************************************************** // if this is an Error or Authentication API - Ignore // ******************************************************** if (url.Contains("/authentication/dev") || url.Contains("/error") || url.Contains("/hangfire") || url.Contains("/swagger")) { _logger.LogInformation("Bypassing authentication process ({0})", url); return(Task.FromResult(AuthenticateResult.NoResult())); } // ************************************************** // check if we have a Dev Environment Cookie // ************************************************** string tempToken = context.Request.Cookies[options.DevAuthenticationTokenKey]; if (hostingEnv.IsDevelopment() && !string.IsNullOrEmpty(tempToken)) { _logger.LogInformation("Dev Authentication token found ({0})", tempToken); userId = tempToken; } else if ((context.Connection.RemoteIpAddress.ToString().StartsWith("::1") || context.Connection.RemoteIpAddress.ToString().StartsWith("::ffff:127.0.0.1")) && url.StartsWith("http://*****:*****@"LOCK TABLE ""HET_USER"" IN EXCLUSIVE MODE;"); HetUser user = dbAppContext.HetUser.First(x => x.UserId == updUserId); user.DistrictId = districtId; dbAppContext.HetUser.Update(user); // update user record dbAppContext.SaveChanges(); // commit transaction.Commit(); } } } userSettings.SiteMinderGuid = siteMinderGuid; userSettings.UserAuthenticated = true; userSettings.BusinessUser = false; } // ************************************************** // validate / check user permissions // ************************************************** _logger.LogInformation("Validating user permissions"); ClaimsPrincipal userPrincipal; if (userSettings.BusinessUser && userSettings.UserAuthenticated && userSettings.HetsBusinessUser != null) { userPrincipal = userSettings.HetsBusinessUser.ToClaimsPrincipal(options.Scheme); if (!userPrincipal.HasClaim(HetUser.PermissionClaim, HetPermission.BusinessLogin)) { _logger.LogWarning(options.MissingDbUserIdError + " (" + userId + ")"); return(Task.FromResult(AuthenticateResult.Fail(options.InvalidPermissions))); } } else { userPrincipal = userSettings.HetsUser.ToClaimsPrincipal(options.Scheme); if (!userPrincipal.HasClaim(HetUser.PermissionClaim, HetPermission.Login) && !userPrincipal.HasClaim(HetUser.PermissionClaim, HetPermission.BusinessLogin)) { _logger.LogWarning(options.MissingDbUserIdError + " (" + userId + ")"); return(Task.FromResult(AuthenticateResult.Fail(options.InvalidPermissions))); } } // ************************************************** // create authenticated user // ************************************************** _logger.LogInformation("Authentication successful: " + userId); _logger.LogInformation("Setting identity and creating session for: " + userId); // ************************************************** // done! // ************************************************** ClaimsPrincipal principal = userPrincipal; return(Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(principal, null, Options.Scheme)))); } catch (Exception exception) { _logger.LogError(exception.Message); Console.WriteLine(exception); throw; } }
public ActionResult EditCollectiveChequeInfo(Models.TransporterChequeViewModel transporterChequeViewModel, int transporterID) { var paymentRequestList = (IEnumerable <Cats.Models.TransporterPaymentRequest>)_transporterPaymentRequestService .Get(t => t.BusinessProcess.CurrentState.BaseStateTemplate.StateNo == 3, null, "BusinessProcess") .OrderByDescending(t => t.TransporterPaymentRequestID); //var transporterChequeObj = _transporterChequeService.Get(t => t.TransporterChequeId == transporterChequeViewModel.TransporterChequeId).FirstOrDefault(); if (paymentRequestList.Any()) { var transporterChequeDetails = new List <TransporterChequeDetail>(); foreach (var paymentRequest in paymentRequestList) { var transporterChequeDetail = new TransporterChequeDetail { TransporterPaymentRequestID = paymentRequest.TransporterPaymentRequestID }; transporterChequeDetails.Add(transporterChequeDetail); } var user = UserAccountHelper.GetUser(User.Identity.Name); var transporterChequeObj = new TransporterCheque() { CheckNo = transporterChequeViewModel.CheckNo, PaymentVoucherNo = transporterChequeViewModel.PaymentVoucherNo, BankName = transporterChequeViewModel.BankName, Amount = transporterChequeViewModel.Amount, PreparedBy = user.UserProfileID, Status = 1, TransporterChequeDetails = transporterChequeDetails }; int BP_PR = _applicationSettingService.getTransporterChequeWorkflow(); if (BP_PR != 0) { BusinessProcessState createdstate = new BusinessProcessState { DatePerformed = DateTime.Now, PerformedBy = "System", Comment = "Created workflow for Transporter Cheque" }; //_PaymentRequestservice.Create(request); BusinessProcess bp = _businessProcessService.CreateBusinessProcess(BP_PR, transporterChequeObj.TransporterChequeId, "ValidatedPaymentRequest", createdstate); transporterChequeObj.BusinessProcessID = bp.BusinessProcessID; transporterChequeObj.IssueDate = DateTime.Now; _transporterChequeService.AddTransporterCheque(transporterChequeObj); foreach (var paymentRequest in paymentRequestList) { var currFlowTemplate = paymentRequest.BusinessProcess.CurrentState.BaseStateTemplate.InitialStateFlowTemplates.FirstOrDefault(); if (currFlowTemplate != null) { var state = new BusinessProcessState() { StateID = currFlowTemplate.FinalStateID, PerformedBy = user.FullName, Comment = "Finance: Batch generated cheque for the payment request", DatePerformed = DateTime.Now, ParentBusinessProcessID = paymentRequest.BusinessProcess.CurrentState.ParentBusinessProcessID }; var item = _businessProcessService.FindById(state.ParentBusinessProcessID); _businessProcessStateService.Add(state); item.CurrentStateID = state.BusinessProcessStateID; _businessProcessService.Update(item); } } } } return(RedirectToAction("Cheques", "Cheque", new { Area = "Finance", transporterID })); }
// // GET: /Home/ // [Authorize] public ActionResult Index() { //var req = _reliefRequistionService.FindBy(t => t.RegionID == regionId); //var req = _regionalRequestService.FindBy(t => t.RegionID == regionId); //ViewBag.Requests = req; var currentUser = UserAccountHelper.GetUser(HttpContext.User.Identity.Name); var userID = currentUser.UserProfileID; if (currentUser.IsAdmin) { return(RedirectToAction("Index", "AdminDashboard", new { Area = "Settings" })); } if (currentUser.DefaultHub != null) { return(RedirectToAction("Index", "Home", new { Area = "Hub" })); } if (currentUser.RegionalUser) { ViewBag.RegionID = currentUser.RegionID; return(RedirectToAction("Index", "Home", new { Area = "Regional" })); } switch (currentUser.CaseTeam) { case 1: return(RedirectToAction("Index", "Home", new { Area = "EarlyWarning" })); break; case 2: return(RedirectToAction("Index", "Home", new { Area = "PSNP" })); break; case 3: return(RedirectToAction("Index", "Home", new { Area = "Logistics" })); break; case 4: return(RedirectToAction("Index", "Home", new { Area = "Procurement" })); break; case 5: return(RedirectToAction("Index", "Home", new { Area = "Finance" })); break; } // If the user is not niether regional nor caseteam user return this default page var userDashboardPreferences = _userDashboardPreferenceService.Get(t => t.UserID == userID).OrderBy(m => m.OrderNo); var dashboardWidgets = userDashboardPreferences.Select(userDashboardPreference => _dashboardWidgetService.FindById(userDashboardPreference.DashboardWidgetID)).ToList(); return(View(dashboardWidgets)); //return Json(req, JsonRequestBehavior.AllowGet); //return Json(req, JsonRequestBehavior.AllowGet); //var widgets = new List<DashboardWidget>(); //return View(widgets); }