Ejemplo n.º 1
0
        public async Task <IActionResult> End(SubmitModel submitModel)
        {
            var result = JsonConvert.DeserializeObject <List <ValueModel> >(submitModel.result);

            var thePaper = paperManager.FindPaperById(submitModel.paperId);

            var topicIdList = JsonConvert.DeserializeObject <List <TopicId> >(thePaper.body);

            if (result.Count == topicIdList.Count)
            {
                int sum = 0;
                for (int i = 0; i < result.Count; i++)
                {
                    var theTopic = topicManager.FindTopicById(topicIdList[i].id);
                    if (theTopic.answe.Equals(result[i].value))
                    {
                        sum += theTopic.scores;
                    }
                }
                var flag = await successManager.CreateSuccessAsync(new SuccessModel {
                    userName = User.Identity.Name,
                    paper    = thePaper.title,
                    scores   = sum,
                    subtotal = thePaper.subtotal
                });

                if (flag)
                {
                    ViewBag.Subtotal = thePaper.subtotal;
                    return(View(sum));
                }
            }
            return(View("Error", new ErrorViewModel {
                RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
            }));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(PaperModel paper)
        {
            //添加创建人
            paper.teacherUserName = HttpContext.User.Identity.Name;
            var topicIdList = JsonConvert.DeserializeObject <List <TopicId> >(paper.body);
            int sum         = 0;

            //计算总分
            foreach (var item in topicIdList)
            {
                sum += topicManager.FindTopicById(item.id).scores;
            }
            paper.subtotal = sum;
            await paperManager.AddPaperAsync(paper);

            List <PaperModel> papers = await paperManager.FindPaperAllAsync();

            return(View("Index", papers));
        }
Ejemplo n.º 3
0
        public IActionResult Detail(int id)
        {
            var topic = topicManager.FindTopicById(id);

            return(View(topic));
        }