Example #1
0
        public IActionResult Edit(ListEditViewModel model)
        {
            switch (model.Type)
            {
            case "Mu":
                MuziekPlaylist mList = _context.MuziekPlaylist.FirstOrDefault(mp => mp.Id == model.Id);
                mList.Titel = model.Titel;
                _context.SaveChanges();
                break;

            case "Fi":
                FilmPlaylist fList = _context.FilmPlaylist.FirstOrDefault(fp => fp.Id == model.Id);
                fList.Titel = model.Titel;
                _context.SaveChanges();
                break;

            case "Se":
                MuziekPlaylist sList = _context.MuziekPlaylist.FirstOrDefault(sp => sp.Id == model.Id);
                sList.Titel = model.Titel;
                _context.SaveChanges();
                break;

            default:
                break;
            }
            return(RedirectToAction("Detail", new { model.Id, model.Type }));
        }
Example #2
0
        public IActionResult Edit(int id, string type)
        {
            ListEditViewModel model = new ListEditViewModel()
            {
                Id = id, Type = type
            };

            switch (type)
            {
            case "Mu":
                model.Titel = _context.MuziekPlaylist.FirstOrDefault(mp => mp.Id == id).Titel;
                break;

            case "Fi":
                model.Titel = _context.FilmPlaylist.FirstOrDefault(fp => fp.Id == id).Titel;
                break;

            case "Se":
                model.Titel = _context.SeriePlaylist.FirstOrDefault(sp => sp.Id == id).Titel;
                break;

            default:
                break;
            }
            return(View(model));
        }
Example #3
0
        public ActionResult OnlineProducts(int currentPage = 1)
        {
            List <NewProductViewModel> lsproduct    = pMgnt.GetOnlineProducts(PageSize, currentPage, out TotalPages);
            ListEditViewModel          listofRecord = new ListEditViewModel();

            listofRecord.Elements   = lsproduct;
            listofRecord.PagingInfo = new PagingInfo()
            {
                TotalItems = TotalPages, CurrentPage = currentPage, ItemsPerPage = PageSize
            };
            return(View(listofRecord));
        }
Example #4
0
        public ActionResult Edit(ListEditViewModel Model)
        {
            var list = Context.Lists.FirstOrDefault(x => x.Id == Model.Id);

            list.Title   = Model.Title;
            list.Content = Model.Content;

            Context.SaveChanges();


            return(Redirect("../ViewAll"));
        }
Example #5
0
        // GET: Product
        public ActionResult Index(int currentPage = 1)
        {
            var CurrentUserId = ((TradeBulk_Web.Authe_AuthoATION.CustomPrincipal)HttpContext.User).UserId;
            List <NewProductViewModel> lsproduct    = pMgnt.GetCurrentUserProductList(CurrentUserId, PageSize, currentPage, out TotalPages);
            ListEditViewModel          listofRecord = new ListEditViewModel();

            listofRecord.Elements   = lsproduct;
            listofRecord.PagingInfo = new PagingInfo()
            {
                TotalItems = TotalPages, CurrentPage = currentPage, ItemsPerPage = PageSize
            };
            return(View(listofRecord));
        }
        public async Task <IActionResult> SaveList([FromBody] ListEditViewModel vm)
        {
            var userId = _caller.Claims.Single(c => c.Type == "id");
            var user   = await _userManager.FindByIdAsync(userId.Value);

            if (user == null)
            {
                return(BadRequest("Not logged in"));
            }

            var list = _context.Lists.FirstOrDefault(x => x.id == vm.id);

            if (list == null)
            {
                list = new List()
                {
                    dateCreated = DateTime.Now,
                    owner       = user,
                    guid        = Guid.NewGuid().ToString()
                };
            }

            list.name        = vm.name;
            list.slug        = vm.slug;
            list.dateUpdated = DateTime.Now;
            list.priority    = vm.priority;
            list.description = vm.description;

            var slugCount = _context.Lists.Where(x => x.slug == list.slug && list.id != list.id).Count();

            if (slugCount > 0)
            {
                list.slug += $"-{slugCount}";
            }

            if (list.id > 0)
            {
                _context.Lists.Update(list);
            }
            else
            {
                await _context.Lists.AddAsync(list);
            }
            await _context.SaveChangesAsync();

            return(Ok(list));
        }