public ActionResult Confirm(int id, string uniqueRadio, string fname, CollectViewModel model)
        {
            using (var collectService = new CollectsService())
            {
                try
                {
                    int selectedId = Int32.Parse(model.Gift.Id);
                    if (ModelState.IsValid)
                    {
                        collectService.ChangeRadioButtonChoose(id, GetUserId(), model.Gift.Id);
                    }
                    collectService.CollectAmountChange(id, model.Amount);
                    collectService.CollectConfirmChange(id, true);

                    //Send Email
                    using (var userService = new UsersService())
                    {
                        var collect = collectService.GetCollect(id);

                        collectService.SendEmailsConfirm(userService.GetUserIndex().Where(i => i.Id != collect.RecipientId).ToList(), collect);
                    }

                    return(RedirectToAction("Details", "Collects", new { id = id }));
                }
                catch (NullReferenceException)
                {
                    ViewBag.MustChooseItem = "Musisz wybrać jakikolwiek prezent !";
                }

                var collectViewModel = collectService.GetCollectViewModel(id, GetUserId());

                return(View(collectViewModel));
            }
        }
        public ActionResult Confirm(int id)
        {
            using (var collectService = new CollectsService())
            {
                var collectViewModel = collectService.GetCollectViewModel(id, GetUserId());

                using (var userService = new UsersService())
                {
                    if (!userService.IsAdmin(GetUserId()))
                    {
                        if (!collectService.IsCollectionsUser(id, GetUserId()))
                        {
                            return(HttpNotFound());
                        }
                    }
                }

                if (collectService.CounterCollectionsGifts(id) == 0)
                {
                    ViewBag.MustChooseItem = "Musisz wybrać któryś z prezentów !";
                }

                return(View(collectViewModel));
            }
        }
        public ActionResult Create([Bind(Include = "Id,RecipientId,Name,Description,Amount,DateOfInitiative")] Collect collect)
        {
            if (ModelState.IsValid)
            {
                using (var collectService = new CollectsService())
                {
                    collect.OwnerId = GetUserId();
                    collectService.CollectAdd(collect);

                    var newCollectionUsers = new CollectUser();
                    newCollectionUsers.UserId    = collect.OwnerId;
                    newCollectionUsers.CollectId = collect.Id;
                    collectService.CollectUserAdd(newCollectionUsers);

                    //Send Email
                    using (var userService = new UsersService())
                    {
                        collectService.SendEmailsCreate(userService.GetUserIndex().Where(i => i.Id != collect.RecipientId).ToList(), collect);
                    }

                    return(RedirectToAction("Details", "Collects", new { id = collect.Id }));
                }
            }

            using (var collectService = new CollectsService())
            {
                ViewBag.OwnerId     = new SelectList(collectService.AllMyUserList(), "Id", "Name", collect.OwnerId);
                ViewBag.RecipientId = new SelectList(collectService.AllMyUserList(), "Id", "Name", collect.RecipientId);
                return(View(collect));
            }
        }
 public ActionResult Index(int id, CollectUsersListBoxViewModel person)
 {
     using (var collectService = new CollectsService())
     {
         var personPost = collectService.GetCollectUsersListBoxViewModelPost(id, person);
         return(View(personPost));
     }
 }
Example #5
0
 public ActionResult LeaveConfirmed(int id)
 {
     using (var collectService = new CollectsService())
     {
         collectService.LeaveConfirmed(id, GetUserId());
         return(RedirectToAction("Index", "Collects"));
     }
 }
Example #6
0
 public ActionResult Leave(int id)
 {
     using (var collectService = new CollectsService())
     {
         var collectViewModel = collectService.GetCollectViewModel(id, GetUserId());
         return(View(collectViewModel));
     }
 }
Example #7
0
 public ActionResult DeleteConfirmed(int id)
 {
     using (var collectService = new CollectsService())
     {
         collectService.CollectGiftDelete(id);
         return(RedirectToAction("Index"));
     }
 }
Example #8
0
 public ActionResult Delete(int id)
 {
     using (var collectService = new CollectsService())
     {
         var collectGift = collectService.GetCollectGift(id);
         return(View(collectGift));
     }
 }
        public ActionResult UndoConfirm(int id)
        {
            using (var collectService = new CollectsService())
            {
                collectService.CollectConfirmChange(id, false);
            }

            return(RedirectToAction("Details", "Collects", new { id = id }));
        }
Example #10
0
 public ActionResult Index(int id)
 {
     using (var collectService = new CollectsService())
     {
         ViewBag.collectId = id;
         var collectionsGifts = collectService.GetCollectsGiftsIndex(id);
         return(View(collectionsGifts));
     }
 }
 public ActionResult Details(int id)
 {
     using (var collectService = new CollectsService())
     {
         ViewBag.InCollect = collectService.IsCollectionsUser(id, GetUserId());
         var collectViewModel = collectService.GetCollectViewModel(id, GetUserId());
         return(View(collectViewModel));
     }
 }
 public ActionResult Create()
 {
     using (var collectService = new CollectsService())
     {
         int userId = GetUserId();
         var modelUsersWithoutThisUser = collectService.AllMyUserList().Where(i => i.Id != userId);
         ViewBag.RecipientId = new SelectList(modelUsersWithoutThisUser, "Id", "Name");
         return(View());
     }
 }
Example #13
0
        public ActionResult GaveMoney(int id)
        {
            using (var collectService = new CollectsService())
            {
                collectService.GaveMoneyChange(id);

                int collectId = collectService.GetCollectId(id);

                return(RedirectToAction("Index", new { id = collectId }));
            }
        }
        public ActionResult Edit([Bind(Include = "Id,OwnerId,RecipientId,Name,Description,Amount,DateOfInitiative,IsActive")] Collect collect)
        {
            if (ModelState.IsValid)
            {
                using (var collectService = new CollectsService())
                    collectService.CollectChange(collect);

                return(RedirectToAction("Index"));
            }
            return(View(collect));
        }
        public ActionResult Index(int?page)
        {
            int userId = GetUserId();

            using (var collectService = new CollectsService())
            {
                var collections = collectService.AllCollectList(userId).Where(i => i.RecipientId != userId).OrderByDescending(i => i.DateOfAdd).ToList();

                int pageSize   = 5;
                int pageNumber = (page ?? 1);
                return(View(collections.ToPagedList(pageNumber, pageSize)));
                //return View(collections);
            }
        }
        public ActionResult Details(int id, CollectViewModel model)
        {
            using (var collectService = new CollectsService())
            {
                ViewBag.InCollect = collectService.IsCollectionsUser(id, GetUserId());

                if (ModelState.IsValid)
                {
                    collectService.ChangeRadioButtonChoose(id, GetUserId(), model.Gift.Id);
                }

                var collectViewModel = collectService.GetCollectViewModel(id, GetUserId());
                return(View(collectViewModel));
            }
        }
Example #17
0
        public ActionResult Create(int?id, [Bind(Include = "Id,Name")] CollectGift collectGift)
        {
            using (var collectService = new CollectsService())
            {
                if (ModelState.IsValid)
                {
                    collectGift.UserId    = GetUserId();
                    collectGift.CollectId = id;
                    collectService.CollectGiftAdd(collectGift);

                    return(RedirectToAction("Details", "Collects", new { id = id }));
                }

                return(View(collectGift));
            }
        }
Example #18
0
        public ActionResult JoinConfirmed(int id)
        {
            using (var collectService = new CollectsService())
            {
                int userId      = GetUserId();
                var collectUser = collectService.GetCollectUser(id);

                if (ModelState.IsValid)
                {
                    collectService.JoinConfirmed(id, GetUserId());

                    return(RedirectToAction("Details", "Collects", new { id = id }));
                }
            }

            return(HttpNotFound());
        }
Example #19
0
        public ActionResult Index(int id)
        {
            using (var collectService = new CollectsService())
            {
                using (var userService = new UsersService())
                {
                    if (!userService.IsOwner(GetUserId()))
                    {
                        return(HttpNotFound());
                    }
                }

                ViewBag.ThisId = id;
                var collectUsers = collectService.GetCollectUserIndex(id);

                return(View(collectUsers));
            }
        }
 public ActionResult Edit(int id)
 {
     using (var collectService = new CollectsService())
         return(View(collectService.GetCollect(id)));
 }