示例#1
0
        public IActionResult Create(FunkoPop model)
        {
            //TODO: need to do user checks
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            try
            {
                model.DateAdded = DateTime.UtcNow;
                _service.Add(model);
            }
            catch (Exception e)
            {
                ShowStatusMessage(MessageTypeEnum.error, e.Message, "Duplicate Pop");

                return(View(model));
            }

            if (SessionValueExists("popWish"))
            {
                _wishService.Delete(Convert.ToInt32(GetFromSession <string>("popWishID")), _user.Id);

                RemoveFromSession("popWish");
                RemoveFromSession("popWishID");
                ShowStatusMessage(MessageTypeEnum.info, "Wish list has been updated", "Wish list");
            }
            ShowStatusMessage(MessageTypeEnum.success, "New Pop Added Successfully.", "Add Successful");

            return(RedirectToAction("Index", "Pop"));
        }
示例#2
0
        public IActionResult Create(Album model)
        {
            //TODO: need to do user checks
            if (ModelState.IsValid)
            {
                try
                {
                    if (model.CompletionStatus == CompletionStatus.Completed && model.TimesCompleted == 0)
                    {
                        model.TimesCompleted = 1;
                    }
                    model.DateAdded = DateTime.UtcNow;
                    SetTimeStamps(model);
                    this._service.Add(model);
                }
                catch (Exception e)
                {
                    ShowStatusMessage(MessageTypeEnum.error, e.Message, "Duplicate Album");
                    return(View(model));
                }
                RemoveFromSession("album-query");

                if (SessionValueExists("wish"))
                {
                    _wishService.Delete(Convert.ToInt32(GetFromSession <string>("wishID")), _user.Id);
                    RemoveFromSession("wish");
                    RemoveFromSession("wishID");
                    ShowStatusMessage(MessageTypeEnum.info, "Wish list has been updated", "Wish list");
                }
                ShowStatusMessage(MessageTypeEnum.success, "New Album Added Successfully.", "Add Successful");
                return(RedirectToAction("Index", "Album"));
            }
            return(View(model));
        }
        // DELETE: api/wishes/5
        public IHttpActionResult Delete(int id)
        {
            //delete the wish
            Wish wish = service.GetById(id);

            service.Delete(wish);
            service.Commit();

            ////delete the kid
            //Kid kid = KidService.GetById(wish.KidID);
            //KidService.Delete(kid);
            //KidService.Commit();

            return(Ok());
        }
示例#4
0
        public IActionResult Delete(int id)
        {
            var model = _service.GetByID(id, _user.Id);

            if (model.UserID != _user.Id)
            {
                ShowStatusMessage(MessageTypeEnum.error, "This wish cannot be deleted by another user", "Delete Failure");
                return(RedirectToAction("Index", "Wish"));
            }

            _service.Delete(id, _user.Id);

            ShowStatusMessage(MessageTypeEnum.success, string.Empty, "Wish Deleted Successfully");
            return(RedirectToAction("Index", "Wish"));
        }
        // [ValidateAntiForgeryToken]
        public JsonResult Delete(int id)
        {
            //delete the wish
            Wish wish = service.GetById(id);

            service.Delete(wish);
            service.Commit();

            //delete the kid
            Kid kid = KidService.GetById(wish.KidID);

            KidService.Delete(kid);
            KidService.Commit();

            return(Json("wish deleted"));
        }
        public IActionResult Create(Book book)
        {
            if (!ModelState.IsValid)
            {
                return(View(book));
            }
            try
            {
                if (book.CompletionStatus == CompletionStatus.Completed && book.TimesCompleted == 0)
                {
                    book.TimesCompleted = 1;
                }
                book.DateAdded = DateTime.UtcNow;
                SetTimeStamps(book);
                this._service.Add(book);
            }
            catch (Exception e)
            {
                ShowStatusMessage(MessageTypeEnum.error, e.Message, "Duplicate Book");

                return(View(book));
            }
            RemoveFromSession("book-query");

            if (SessionValueExists("wish"))
            {
                _wishService.Delete(Convert.ToInt32(GetFromSession <string>("wishID")), _user.Id);
                RemoveFromSession("wish");
                RemoveFromSession("wishID");
                ShowStatusMessage(MessageTypeEnum.info, "Wish list has been updated", "Wish list");
            }

            ShowStatusMessage(MessageTypeEnum.success, "New Book Added Successfully.", "Add Successful");

            return(RedirectToAction("Index", "Book"));
        }