public async Task <IActionResult> GetUpdate(int id) { try { var entity = await Manager.FindById(id); var TravellersList = await TravellersManager.All(); var TravelList = await TravelsManager.All(); RequestsViewModel viewModel = new RequestsViewModel { Travellers = new Travellers { ID_Travellers = entity.travellers.ID_Travellers }, Travels = new Travels { ID_Travels = entity.travels.ID_Travels }, ID_Requests = entity.ID_Requests }; FillTravellersList(viewModel, TravellersList.ToList()); FillTravelList(viewModel, TravelList.ToList()); viewModel.Requests = await Manager.All(); return(View("Index", viewModel)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
private RequestsViewModel PrepareModel() { var requestsViewModel = new RequestsViewModel(); CreateRequestsList(requestsViewModel); return(requestsViewModel); }
public async Task <IActionResult> Post(RequestsViewModel viewModel) { try { if (!ModelState.IsValid) { return(View("Form", viewModel)); } await Manager.Save(new Requests { ID_Requests = viewModel.ID_Requests, travellers = new Travellers { ID_Travellers = viewModel.Travellers.ID_Travellers }, travels = new Travels { ID_Travels = viewModel.Travels.ID_Travels } }); return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError("Error", ex.Message); return(View("Form", viewModel)); } }
public ActionResult Index(string option, string userType) { if (option != null) { switch (option.ToLower()) { case "updateinfo": { _viewModel = new UpdateInfoViewModel(); CreateLayoutView("Cập nhật thông tin"); break; } case "updatepassword": { _viewModel = new UpdatePasswordViewModel(); CreateLayoutView("Cập nhật mật khẩu"); break; } case "updatesetting": { _viewModel = new UpdateSettingViewModel(); CreateLayoutView("Cài đặt"); break; } case "notification": { _viewModel = new NotificationViewModel(); CreateLayoutView("Thông báo"); break; } case "requests": { _viewModel = new RequestsViewModel(); CreateLayoutView("Lời mời kết bạn"); break; } default: { _viewModel = new UpdateInfoViewModel(); CreateLayoutView("Cập nhật thông tin"); break; } } } else { _viewModel = new UpdateInfoViewModel(); CreateLayoutView("Cập nhật thông tin"); } ViewBag.newMember = userType; ViewBag.listRequest = _friendService.GetRelationship(User.Identity.GetUserId()).Count - 1; ViewBag.listNotification = _notificationService.getAllNotification(User.Identity.GetUserId()).Count - 1; return(View(_viewModel)); }
public async Task <IActionResult> DeclineOffer(RequestsViewModel model) { var transactionId = model.TransactionId; var offer = _transactionRepository.Transactions.FirstOrDefault(t => t.Id == transactionId); var adminId = await GetUserId(); //offer declined(type = -2) processed by admin offer.IsProcessed = 1; offer.DateProcessed = DateTime.Now; offer.RecipientId = adminId; offer.Type = -2; offer.Price = 0m; //just for safety _transactionRepository.UpdateTransaction(offer); //send notification to member var item = offer.TransactionItem.First().Item; var quantity = offer.TransactionItem.First().Quantinty; var message = new Message() { SenderId = adminId, ReceiverId = offer.OwnerId, DateSent = DateTime.Now, Title = "Offer declined", Message1 = $"We are sorry to inform you that your offer for {quantity} {item.UnitType} {item.Name} has been declined.<br> Thanks for your attention, consideration, and time,<br> Co-Partenership" }; _messageInterface.SaveMessage(message); return(RedirectToAction(nameof(Requests))); }
public ActionResult View_Recent_Requests() { RequestsDal pdal = new RequestsDal(); var pm = new RequestsViewModel(); pm.ListRequests = pdal.GetAllRequestsSentToMe(Session["Username"].ToString()); return(View(pm)); }
public RequestsController(ApplicationDbContext db, IConfiguration configuration) { _db = db; RequestsVM = new RequestsViewModel() { ProblemTypes = _db.ProblemTypes.ToList(), Requests = new Models.Requests() }; _configuration = configuration; }
private static void AreDetailsModelsEqual(RequestsViewModel expected, RequestsViewModel actual) { Assert.AreEqual(expected.Id, actual.Id, "Requests ID does not match"); Assert.AreEqual(expected.Content, actual.Content, "Requests Content are different"); Assert.AreEqual(expected.AdminName, actual.AdminName, "Requests AdminName are different"); Assert.AreEqual(expected.Date, actual.Date, "Requests Date are different"); Assert.AreEqual(expected.Status, actual.Status, "Requests Status are different"); Assert.AreEqual(expected.UpdateDate, actual.UpdateDate, "Requests UpdateDate are different"); Assert.AreEqual(expected.UsersEmail, actual.UsersEmail, "Requests UsersEmail are different"); }
public ReceivedRequestsController(ApplicationDbContext db, UserManager <IdentityUser> userManager, IConfiguration configuration) { _db = db; RequestsVM = new RequestsViewModel() { ProblemTypes = _db.ProblemTypes.ToList(), Requests = new Models.Requests() }; _userManager = userManager; _configuration = configuration; }
public ActionResult Index() { FindFaqRequestsQueryResult result = Query.For <FindFaqRequestsQueryResult>().With(new EmptyCriterion()); RequestsViewModel vm = new RequestsViewModel { Requests = result.Requests }; return(View(vm)); }
public async Task <IActionResult> Edit(RequestsViewModel model) { if (model == null) { return(StatusCode(StatusCodes.Status400BadRequest)); } if (ModelState.IsValid) { await repository.EditRequest((Requests)modelMapper.Map(model, typeof(RequestsViewModel), typeof(Requests))); } return(RedirectToAction("Edit", model)); }
public async Task <IActionResult> Index() { RequestsViewModel viewModel = new RequestsViewModel(); var TravellersList = await TravellersManager.All(); var TravelList = await TravelsManager.All(); FillTravellersList(viewModel, TravellersList.ToList()); FillTravelList(viewModel, TravelList.ToList()); viewModel.Requests = await Manager.All(); return(View(viewModel)); }
protected override void HandleOnNavigatedTo(NavigationEventArgs e) { base.HandleOnNavigatedTo(e); if (this._isInitialized) { return; } RequestsViewModel requestsViewModel = new RequestsViewModel(long.Parse(((Page)this).NavigationContext.QueryString["CommunityId"])); base.DataContext = requestsViewModel; requestsViewModel.Requests.LoadData(true, false, null, false); this._isInitialized = true; }
public ActionResult requests() { if ((Session["userId"] == null) || (Convert.ToInt32(Session["type"]) != 3)) { return(RedirectToAction("login", "Common")); } RequestsViewModel RVM = new RequestsViewModel(); RVM.admin = _AdminService.GetById(Convert.ToInt32(Session["userId"])); return(View(RVM)); }
/// <summary> /// Feedback details. /// </summary> /// <param name="id"> Feedback Id. </param> /// <returns> The <see cref="ActionResult"/>. </returns> public ActionResult Details(int id) { var feedback = _feedbackService.GetDetails(id); if (feedback == null) { return(HttpNotFound()); } var feedbackModel = new RequestsViewModel(feedback); return(View(feedbackModel)); }
public async Task <IActionResult> Requests() { var trainer = await this.userManager.GetUserAsync(this.User); string trainerId = await this.userManager.GetUserIdAsync(trainer); var viewModel = new RequestsViewModel() { Requests = await this.appointmentsService .GetAppointmentRequestsForTrainer <RequestViewModel>(trainerId), }; return(this.View(viewModel)); }
public ActionResult Index(RequestStatus status) { var parentQuery = unitOfWork.Requests.GetRequestsByStatus(status);//1 var requests = parentQuery.Include(r => r.Individual).ToList(); parentQuery.OfType <BankAccRequest>().Include(r => r.BankAccType).Load(); var viewModel = new RequestsViewModel { Requests = requests.ToList(), Status = status }; return(View(viewModel)); }
private RequestsViewModel CreateRequestsViewModel(AddRequestViewModel addRequestViewModel = null) { var model = new RequestsViewModel(); model.AppointmentsWait = _appointmentsService.GetWaitingAppointments(CurrentUserType, CurrentUserId); model.AppointmentsAccepted = _appointmentsService.GetAcceptedAppointments(CurrentUserType, CurrentUserId); model.AppointmentsRefused = _appointmentsService.GetRefusedAppointments(CurrentUserType, CurrentUserId); model.CanAcceptOrRefuseAppointments = IsCurrentUserStaff; if (addRequestViewModel != null) { model.AddRequestViewModel = addRequestViewModel; model.OpenAddRequestModal = true; } model.AddRequestViewModel.Doctors = _staffService.GetStaffs(); return(model); }
public ActionResult Requests() { bool flag = false; _viewModel = new RequestsViewModel(); CreateLayoutView("Lời mời kết bạn"); List <Friend> listRequest = _friendService.GetRelationship(User.Identity.GetUserId()); foreach (Friend friend in listRequest) { NotiFriendViewModel notiFriendViewModel = new NotiFriendViewModel(); ApplicationUser userT = new ApplicationUser(); if (friend != null) { switch (flag) { case false: { userT = _service.GetUserById(friend.Id_User); notiFriendViewModel.Flag = false; break; } case true: { userT = _service.GetUserById(friend.Id_Friend); notiFriendViewModel.Flag = true; break; } } FieldHelper.CopyNotNullValue(notiFriendViewModel, userT); FieldHelper.CopyNotNullValue(notiFriendViewModel, friend); RequestsViewModel.ListRequest.Add(notiFriendViewModel); } else { flag = true; } } RequestsViewModel.ListRequest.OrderBy(x => x.CreatedDate); ViewBag.listRequest = listRequest.Count - 1; ViewBag.listNotification = _notificationService.getAllNotification(User.Identity.GetUserId()).Count; return(PartialView("_Requests", RequestsViewModel)); }
public void Details_FeedbackWithReplies_DetailsModelReturned() { // Arrange const int FEEDBACK_ID = 1; var feedback = GetAnyFeedback(FEEDBACK_ID); MockGetFeedback(FEEDBACK_ID, feedback); var expected = new RequestsViewModel(feedback); var sut = BuildSut(); // Act var actionResult = sut.Details(FEEDBACK_ID); // Assert var actual = TestExtensions.GetModel <RequestsViewModel>(actionResult); AreDetailsModelsEqual(expected, actual); }
private void CreateRequestsList(RequestsViewModel requestsViewModel) { List <RequestModel> requests = new List <RequestModel>(); var currentUser = _userManager.FindByIdAsync(User.FindFirstValue(ClaimTypes.NameIdentifier)).Result; if (currentUser != null) { if (currentUser.IsSystemAdmin) { requests = _context.Requests.ToList(); } else { requests = _context.Requests.Where(r => r.TargetedUserId == currentUser.Id || r.TargetUserId == currentUser.Id).ToList(); } } var requestsList = new List <RequestViewModel>(); if (requests.Count > 0) { foreach (var request in requests) { var targetUserName = _userManager.FindByIdAsync(request.TargetUserId).Result.UserName; var targetedUserName = _userManager.FindByIdAsync(request.TargetedUserId).Result.UserName; requestsList.Add(new RequestViewModel() { TargetedUser = targetedUserName, TargetUser = targetUserName, RequestId = request.Id.ToString(), Date = request.Date }); requestsViewModel.RequestsList = requestsList; } } else { requestsViewModel.RequestsList = requestsList; } }
public async Task <IActionResult> DeclineOrder(RequestsViewModel model) { var transactionId = model.TransactionId; var order = _transactionRepository.Transactions.FirstOrDefault(t => t.Id == transactionId); var adminId = await GetUserId(); //order declined (type = -1) by admin order.IsProcessed = 1; order.DateProcessed = DateTime.Now; order.RecipientId = adminId; order.Type = -1; order.Price = 0; _transactionRepository.UpdateTransaction(order); //return products to repo foreach (var transactionItem in order.TransactionItem) { var itemId = transactionItem.ItemId; var quantity = transactionItem.Quantinty; var item = _itemRepository.GetItem((int)itemId); item.StockQuantity += quantity; _itemRepository.UpdateItem(item); } //send notification to client var items = string.Join(',', order.TransactionItem .Select(ti => ti.Item.Name) .ToArray()); var message = new Message() { SenderId = adminId, ReceiverId = order.OwnerId, DateSent = DateTime.Now, Title = "Your Order is cancel", Message1 = $"We are sorry to inform you that your order for {items} cannot be completed right now. Feel free to contact us for more information. We hope to see you again soon.<br> Have a great day,<br> Co-Partenership" }; _messageInterface.SaveMessage(message); return(RedirectToAction(nameof(Requests))); }
// GET: Request public ActionResult Index() { if (Session["UserName"] == null) { Response.Redirect("/Account/Login"); } var stuEmail = Convert.ToString(Session["UserName"]); var userID = db.StudentDetails.Where(x => x.Student_Email == stuEmail).Select(x => x.Student_ID).FirstOrDefault(); var posted = (from a in db.Requests join b in db.Communities on a.CommunityID equals b.Community_ID where a.RequestorID == userID select new RequestsPosted() { RequesteeID = a.RequesteeID, AptNo = a.AptNo, CommunityName = b.Community_Name, CommunityID = a.CommunityID }).ToList(); var received = (from a in db.Requests join b in db.Communities on a.CommunityID equals b.Community_ID join s in db.StudentDetails on a.RequestorID equals s.Student_ID where a.RequesteeID == userID && s.Student_ID == a.RequestorID select new RequestsReceived() { Student_Name = s.Student_FirstName + " " + s.Student_LastName, Student_Phone = s.Student_Phone, RequestorID = a.RequestorID, AptNo = a.AptNo, CommunityName = b.Community_Name, CommunityID = a.CommunityID }).ToList(); RequestsViewModel reqObj = new RequestsViewModel(); reqObj.RequestsPosted = posted; reqObj.RequestsReceived = received; return(View(reqObj)); }
private void ShowAllRequestDelegate(Guid id) { if (_selectedClient == null) { return; } var vm = new RequestsViewModel(_requestRepo); vm.ClientId = _selectedClient.ClientId; vm.Initialise(); var uc = new UcRequests(); uc.SetDataContext(vm); var mainStack = MainStackPanel; mainStack.Children.Clear(); mainStack.Children.Add(uc); }
public async Task <IActionResult> AcceptOrder(RequestsViewModel model) { var transactionId = model.TransactionId; var order = _transactionRepository.Transactions.FirstOrDefault(t => t.Id == transactionId); var adminId = await GetUserId(); //order shipped by admin order.DateProcessed = DateTime.Now; order.IsProcessed = 1; order.RecipientId = adminId; _transactionRepository.UpdateTransaction(order); // get clients money and balance it to member & coopshare var companyAccount = _compAccount.Account; var price = order.Price / 2m; companyAccount.CoOpShare += price; companyAccount.MemberShare += price; companyAccount.Date = DateTime.Now; _compAccount.UpdateAccount(companyAccount); //send notification to user var items = string.Join(',', order.TransactionItem .Select(ti => ti.Item.Name) .ToArray()); var message = new Message() { SenderId = adminId, ReceiverId = order.OwnerId, DateSent = DateTime.Now, Title = "Your Order is being shipped", Message1 = $"Your order for {items} is being shipped. We hope to see you again soon.<br> Have a great day,<br> Co-Partenership" }; _messageInterface.SaveMessage(message); return(RedirectToAction(nameof(Requests))); }
public IActionResult Requests() { ViewBag.CurrentChoice = ControllerContext.RouteData.Values["action"].ToString(); var model = new RequestsViewModel() { PendingOffers = _transactionRepository.Transactions .Where(t => t.IsProcessed == 0 && t.Type == 2).ToList(), PendingOrders = _transactionRepository.Transactions .Where(t => t.IsProcessed == 0 && t.Type == 1).ToList(), Addresses = new List <Address>() }; foreach (var order in model.PendingOrders) { var address = _addressRepository.AddressRepo .FirstOrDefault(a => a.TransactionId == order.Id); if (address != null) { model.Addresses.Add(address); } } return(View(model)); }
public IHttpActionResult GetRequests(int id) { try { var requests = requestGroupService.GetMany(r => r.GroupId == id); if (requests.Count() == 0) { return(Ok(requests)); } var requstsVM = new RequestsViewModel() { Group = AutoMapper.Mapper.Map <Group, GroupViewModel>(requestGroupService.GetGroup(requests.First().GroupId)), Users = AutoMapper.Mapper.Map <List <ApplicationUser>, List <UserViewModel> >(requestGroupService.GetUsers(requests.Select(r => r.UserId).ToList()).ToList()) }; return(Ok(requstsVM)); } catch (Exception) { return(BadRequest()); } }
public IActionResult Index() { RequestsViewModel viewModel = new RequestsViewModel(); return(View(viewModel)); }
public RequestsPage() { Title = "Materias disponibles"; InitializeComponent(); BindingContext = viewModel = new RequestsViewModel(); }
// TODO: Update public RequestsViewModel GetInvitationsViewModel(string teamName) { RequestsViewModel model = new RequestsViewModel(); return(model); }