Beispiel #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                if (Review.ReviewContent != null)
                {
                    ViewData["ReviewContent"] = Review.ReviewContent;
                }
                return(Page());
            }

            string evalText = Request.Form["editContent"];

            Review.ReviewType             = OnGetPredictSentiment(evalText);
            _context.Attach(Review).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                var user = await _userManager.GetUserAsync(User);

                logger.Info("{user} updated review on article carrying - id {id} on {date}", user.Email, Review.ArticleId, DateTime.Now);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ReviewExists(Review.UserId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("/Article/Details", new { id = Review.ArticleId }));
        }
Beispiel #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var ppRemoveIds = _context.CategoryParentParameter.Where(c => EF.Property <int>(c, "CategoryId") == Category.CategoryId);

            foreach (var ppRemoveIdsFE in ppRemoveIds)
            {
                _context.CategoryParentParameter.Remove(ppRemoveIdsFE);
            }

            _context.Attach(Category).State = EntityState.Modified;

            int CategoryId = Category.CategoryId;

            parentParamterIds = Request.Form["AddParentParameters"];

            if (parentParamterIds != null)
            {
                string[] parentParamterIdsArrayString = parentParamterIds.Split(",");
                int[]    parentParamterIdsArrayInt    = new int[parentParamterIdsArrayString.Length];
                for (int i = 0; i < parentParamterIdsArrayString.Length; i++)
                {
                    parentParamterIdsArrayInt[i] = Convert.ToInt32(parentParamterIdsArrayString[i].ToString());
                }

                foreach (var ppId in parentParamterIdsArrayInt)
                {
                    CategoryParentParameter = new Data.CategoryParentParameter()
                    {
                        CategoryId        = CategoryId,
                        ParentParameterId = ppId
                    };
                    _context.CategoryParentParameter.Add(CategoryParentParameter);
                    await _context.SaveChangesAsync();
                }
            }


            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategoryExists(Category.CategoryId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            var user = await _userManager.GetUserAsync(User);

            logger.Info("{user} edited category {category} - carrying {id} on {date}", user.Email, Category.CategoryName, Category.CategoryId, DateTime.Now);
            return(RedirectToPage("../Categories"));
        }