Beispiel #1
0
        public JsonResult LessonEdit(int LessonId, LessonModel LessonModel)
        {
            try
            {
                if (LessonId == 0)
                {
                    Core3Base.Infra.Data.Entity.Lesson Lesson = new Core3Base.Infra.Data.Entity.Lesson
                    {
                        LessonName = LessonModel.Lesson.LessonName,
                        IsActive   = LessonModel.Lesson.IsActive,
                    };


                    return(Json(_LessonService.Add(Lesson).HttpGetResponse()));
                }
                else
                {
                    var Lesson = _LessonService.GetLessonById(LessonId).Result;

                    Lesson.LessonName   = LessonModel.Lesson.LessonName;
                    Lesson.IsActive     = LessonModel.Lesson.IsActive;
                    Lesson.DateModified = DateTime.Now;

                    return(Json(_LessonService.Update(Lesson).HttpGetResponse()));
                }
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
        }
 public IActionResult AddLesson(LessonDTO entity)
 {
     if (entity.StartingDate > DateTime.Now)
     {
         if (entity.EndDate > entity.StartingDate)
         {
             if (ModelState.IsValid)
             {
                 var entities = new Lesson()
                 {
                     LessonName      = entity.LessonName,
                     StartingDate    = entity.StartingDate,
                     EndDate         = entity.EndDate,
                     Price           = entity.Price,
                     TransactionTime = DateTime.Now
                 };
                 _lessonService.Add(entities);
                 return(RedirectToAction("ListLesson"));
             }
             return(View(entity));
         }
         else
         {
             TempData["message"] = "Başlangıç Tarihi Bitiş Tarihinden Sonra olamaz";
             return(new RedirectResult("/Admin/AddLesson"));
         }
     }
     else
     {
         TempData["message"] = "Geçmiş Tarihten Başlayamaz";
         return(new RedirectResult("/Admin/AddLesson"));
     }
 }
 public IActionResult Lesson(LessonViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         _lessonService.Add(viewModel.Lesson);
     }
     return(RedirectToAction("Index"));
 }
        public async Task <IHttpActionResult> Add(LessonAddDto model)
        {
            bool result = await _lessonService.Add(model);

            if (!result)
            {
                return(BadRequest());
            }

            return(Ok());
        }
Beispiel #5
0
 public ActionResult Create(Lesson model)
 {
     if (ModelState.IsValid)
     {
         lessonService.Add(model);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
Beispiel #6
0
 public IActionResult Post([FromBody] Lesson lesson)
 {
     try
     {
         return(Ok(_lessonService.Add(lesson).ToApiModel()));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("AddLesson", ex.Message);
         return(BadRequest(ModelState));
     }
 }
Beispiel #7
0
        public IActionResult Add([FromQuery] LessonViewModel model)
        {
            var LessonResponse = _LessonService.Add(new Lesson
            {
                LessonName = model.LessonName
            });

            if (LessonResponse.IsSucceeded && LessonResponse.Result != null)
            {
                return(Ok(LessonResponse.Result));
            }
            return(LessonResponse.HttpGetResponse());
        }
        public async Task <IActionResult> Add(LessonDto lessonDto)
        {
            try
            {
                await _lessonService.Add(lessonDto);

                return(Ok("Ders Başarıyla Kaydedildi"));
            }
            catch
            {
                return(BadRequest("Ders Ekleme İşlemi Başarısız"));
            }
        }
Beispiel #9
0
        private void btnAddLesson_Click(object sender, EventArgs e)
        {
            var    depCode = _departmentService.GetAll().Select(p => p.DepartmentCode).ToList();
            Random random  = new Random();

            foreach (var item in depCode)
            {
                cbxAddLessonLecturer.DataSource = _lecturerService.GetLecturerNames().Where(p => p.StartsWith(item.Remove(0, 1))).ToList();
                int l = random.Next(3, 8);
                for (int i = 1; i < l; i++)
                {
                    cbxAddLessonLecturer.SelectedIndex = random.Next(cbxAddLessonLecturer.Items.Count);

                    _lessonService.Add(new Lesson
                    {
                        LessonCode     = item + '0' + i,
                        LessonCredit   = random.Next(1, 8).ToString(),
                        Classroom      = random.Next(1, 10).ToString(),
                        DepartmentCode = item,
                        LecturerNo     = cbxAddLessonLecturer.Text.Split(' ')[0]
                    });
                }
            }

            /* _lessonService.Add(new Lesson
             * {
             *   LessonCode = tbxAddLessonCode.Text,
             *   LessonCredit = tbxAddLessonCredit.Text,
             *   Classroom = tbxAddLessonClassroom.Text,
             *   DepartmentCode = cbxAddLessonDepartment.Text.Split(' ')[0],
             *   LecturerNo = cbxAddLessonLecturer.Text.Split(' ')[0]
             * });*/
            LoadLessons();

            //Reset();
        }
Beispiel #10
0
 public ActionResult Create(dersler dersler)
 {
     lessonService.Add(dersler);
     return(View("List"));
 }
        public void Add_AddLesson_Verify_MethodCalled()
        {
            //Arrange
            Teacher teacher = new Teacher
            {
                Name    = "Roman",
                Surname = "Kutsenko",
                Post    = "Teacher",
                Lessons = new List <Lesson>()
            };
            Group group = new Group
            {
                CourseNumber = 1,
                GroupNumber  = 19,
                Lessons      = new List <Lesson>()
            };

            Lesson[] lessons =
            {
                new Lesson
                {
                    WeekNumber   = Week.FirstWeek,
                    DayOfTheWeek = Day.Thursday,
                    LessonNumber = 1,
                    LessonName   = "Programming",
                    Group        = group,
                    Teacher      = teacher
                },
                new Lesson
                {
                    WeekNumber   = Week.SecondWeek,
                    DayOfTheWeek = Day.Monday,
                    LessonNumber = 3,
                    LessonName   = "Math",
                    Group        = group,
                    Teacher      = teacher
                },
                new Lesson
                {
                    WeekNumber   = Week.FirstWeek,
                    DayOfTheWeek = Day.Tuesday,
                    LessonNumber = 3,
                    LessonName   = "Philosophy",
                    Group        = group,
                    Teacher      = teacher
                }
            };
            Mock <ILessonService> service = new Mock <ILessonService>();

            service.Setup(mock => mock.Add(lessons[0])).Verifiable();
            service.Setup(mock => mock.Add(lessons[1])).Verifiable();
            service.Setup(mock => mock.Add(lessons[2])).Verifiable();

            //Act
            ILessonService Service = service.Object;

            Service.Add(lessons[0]);
            Service.Add(lessons[1]);
            Service.Add(lessons[2]);

            //Assert
            service.VerifyAll();
        }