示例#1
0
        public RedirectToRouteResult NewNews(New news)
        {
            if (news.title == null || news.category == null || news.text == null || news.description == null)
            {
                newValid = false;
                return(RedirectToAction("Index", "Account"));
            }
            else
            {
                int idUser = 0;
                if (JsonController.changeUser > 0)
                {
                    idUser = UserService.user.userId;
                    UserService.ChangeUser(JsonController.changeUser);
                }
                newValid = true;
                if (NewService.InsertNew(UserService.user, news))
                {
                    TagService.InsertTags(JsonController.tagList);
                    NewsTagsService.InserNewPairs(JsonController.tagList, news.title);
                    myNews.Push(NewService.newStack.FirstOrDefault());
                    newExist = false;
                    if (idUser > 0)
                    {
                        UserService.ChangeUser(idUser);
                        idUser = 0;
                    }

                    return(RedirectToAction("StartPage", "Home"));
                }
                else
                {
                    newExist = true;
                }
            }
            return(RedirectToAction("Index", "Account"));
        }