Пример #1
0
        public async Task <IActionResult> EditLectureGroup(LectureGroup lgroup)
        {
            if (!string.IsNullOrEmpty(HttpContext.Request.Form["Active"].ToString()))
            {
                lgroup.Active = true;
            }
            else
            {
                lgroup.Active = false;
            }

            var msg = 0;

            try
            {
                repo.Update(lgroup);
                await repo.SaveAll();

                msg = 1;
            }
            catch
            {
                msg = 2;
            }
            return(Ok(msg));
        }
Пример #2
0
        public async Task <IActionResult> AddLectureGroup(IFormCollection fc)
        {
            var a        = Convert.ToInt16(fc["counter"]);
            var userid   = HttpContext.Session.GetInt32("userid") ?? 1;
            var date     = DateTime.Now;
            var host     = HttpContext.Connection.RemoteIpAddress.ToString();
            var courseid = Convert.ToInt32(fc["courseid_0"]);

            for (int i = 0; i <= a; i++)
            {
                var lect_group = new LectureGroup()
                {
                    Active   = Convert.ToBoolean(fc["active_" + i]),
                    CourseId = courseid,
                    Row      = Convert.ToInt32(fc["row_" + i]),
                    Title    = fc["title_" + i].ToString()
                };
                Method.CrtFill(lect_group, userid, date, host);

                if (!string.IsNullOrEmpty(lect_group.Title))
                {
                    repo.Add(lect_group);
                }
            }
            await repo.SaveAll();

            return(RedirectToAction("AddLecture", new { courseid = courseid }));
        }