Ejemplo n.º 1
0
        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));
            }
        }
Ejemplo n.º 2
0
        private RequestsViewModel PrepareModel()
        {
            var requestsViewModel = new RequestsViewModel();

            CreateRequestsList(requestsViewModel);
            return(requestsViewModel);
        }
Ejemplo n.º 3
0
        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));
            }
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        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)));
        }
Ejemplo n.º 6
0
        public ActionResult View_Recent_Requests()
        {
            RequestsDal pdal = new RequestsDal();
            var         pm   = new RequestsViewModel();

            pm.ListRequests = pdal.GetAllRequestsSentToMe(Session["Username"].ToString());

            return(View(pm));
        }
Ejemplo n.º 7
0
 public RequestsController(ApplicationDbContext db, IConfiguration configuration)
 {
     _db        = db;
     RequestsVM = new RequestsViewModel()
     {
         ProblemTypes = _db.ProblemTypes.ToList(),
         Requests     = new Models.Requests()
     };
     _configuration = configuration;
 }
Ejemplo n.º 8
0
 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;
 }
Ejemplo n.º 10
0
        public ActionResult Index()
        {
            FindFaqRequestsQueryResult result = Query.For <FindFaqRequestsQueryResult>().With(new EmptyCriterion());

            RequestsViewModel vm = new RequestsViewModel
            {
                Requests = result.Requests
            };

            return(View(vm));
        }
Ejemplo n.º 11
0
 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));
 }
Ejemplo n.º 12
0
        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));
        }
Ejemplo n.º 13
0
        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;
        }
Ejemplo n.º 14
0
        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));
        }
Ejemplo n.º 16
0
        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));
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 19
0
        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));
        }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 21
0
        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;
            }
        }
Ejemplo n.º 22
0
        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)));
        }
Ejemplo n.º 23
0
        // 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));
        }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 25
0
        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)));
        }
Ejemplo n.º 26
0
        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));
        }
Ejemplo n.º 27
0
        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());
            }
        }
Ejemplo n.º 28
0
        public IActionResult Index()
        {
            RequestsViewModel viewModel = new RequestsViewModel();

            return(View(viewModel));
        }
Ejemplo n.º 29
0
 public RequestsPage()
 {
     Title = "Materias disponibles";
     InitializeComponent();
     BindingContext = viewModel = new RequestsViewModel();
 }
Ejemplo n.º 30
0
        // TODO: Update
        public RequestsViewModel GetInvitationsViewModel(string teamName)
        {
            RequestsViewModel model = new RequestsViewModel();

            return(model);
        }