Esempio n. 1
0
        public async Task <IActionResult> CreateMagazine(MagazineVM model)
        {
            if (string.IsNullOrEmpty(LoggedInName()) || !IsAllowed(UserLevel.AccessArea.MagazineAdmin))
            {
                return(RedirectToAction("Login", "User"));
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var folderName = model.MagazineName.Replace(" ", "");
            var result     = await SaveMagazineImage(model.MainImage, folderName)
                             .ConfigureAwait(false);

            var magazine = new Magazine
            {
                Name        = model.MagazineName,
                CreatedBy   = HttpContext.Session.GetString("Name"),
                DateCreated = DateTime.Now,
                Image       = model.MainImage.FileName,
                FolderName  = folderName,
                MagazineId  = _rnd.Next(1001, 9999).ToString(),
            };

            await _magazineManager.CreateMagazine(magazine);

            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public IActionResult CreateMagazine()
        {
            var model = new MagazineVM
            {
                CreatedBy   = LoggedInName(),
                CreatedDate = DateTime.Now
            };

            return(View(model));
        }