예제 #1
0
        public async Task <IActionResult> AddNew(New nw)
        {
            nw.TimeNew = DateTime.Now;
            await _newService.AddNew(nw);

            return(RedirectToAction("AllNew", "New"));
        }
예제 #2
0
        public async Task <IActionResult> AddNew(AddNewViewModel input, IFormFile NewImage)
        {
            if (ModelState.IsValid)
            {
                input.PhotographyAddictedUserId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

                var newId = await newService.AddNew(input, NewImage);

                if (newId == 0)
                {
                    ModelState.AddModelError(string.Empty, "Picture is bigger than 256kb");
                    return(this.View(input));
                }

                return(this.RedirectToAction("PreviewNews", "News"));
            }
            else
            {
                return(this.View(input));
            }
        }