예제 #1
0
        public ActionResult Create()
        {
            LessonVM model = new LessonVM();

            model.Course = courseBL.GetAllCourses();
            return(View(model));
        }
예제 #2
0
 public Lesson AddLesson(LessonVM model)
 {
     if (ModelState.IsValid)
     {
         return(lessonOperation.AddLesson(model));
     }
     else
     {
         return(new Lesson());
     }
 }
예제 #3
0
 public ActionResult LessonTable(LessonVM model)
 {
     using (var MyService = new ServiceReference.Service1Client())
     {
         model.Adı       = "Ders Adı Giriniz";
         model.GecmeNotu = 60;
         MyService.InsertLesson(new ServiceReference.Lesson {
             Id = model.Id, Adi = model.Adı, Büt = model.Büt, BütTahmin = model.BütTahmin, Final = model.Final, FinalDurum = model.FinalDurum, FinalTahmin = model.FinalTahmin, Vize = model.Vize, VizeDurum = model.VizeDurum, VizeTahmin = model.VizeTahmin, GecmeNotu = model.GecmeNotu, GecerNot = model.GecerNot, StudentId = Convert.ToInt32(Session["UserId"].ToString())
         });
     }
     return(RedirectToAction("LessonTable"));
 }
        public void InsertOrUpdate(LessonVM lessonVM)
        {
            var client = new HttpClient
            {
                BaseAddress = new Uri("http://localhost:12280/api/")
            };
            var myContent   = JsonConvert.SerializeObject(lessonVM);
            var buffer      = System.Text.Encoding.UTF8.GetBytes(myContent);
            var byteContent = new ByteArrayContent(buffer);

            byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            if (lessonVM.Id.Equals(0))
            {
                var result = client.PostAsync("Lessons", byteContent).Result;
            }
            else
            {
                var result = client.PutAsync("Lessons/" + lessonVM.Id, byteContent).Result;
            }
        }
예제 #5
0
        public LessonVM GetLessonwDetail(int lessonID)
        {
            Lesson model = Services.Lesson.FirstOrDefault(x => x.ID == lessonID);

            if (model != null)
            {
                LessonDetail detail = model.LessonDetail;
                LessonVM     _model = new LessonVM();
                _model.Description = detail.Description;
                _model.Minitues    = detail.Minitues;
                _model.Subject     = detail.Subject;
                _model.Name        = model.Name;
                _model.StartDate   = model.StartDate;
                _model.TeacherID   = model.TeacherID;
                return(_model);
            }
            else
            {
                return(new LessonVM());
            }
        }
예제 #6
0
        public Lesson AddLesson(LessonVM model)
        {
            User teacher = Services.User.FirstOrDefault(x => x.ID == model.TeacherID && x.AccountType == (int)EnumUserType.Teacher);
            User admin   = Services.User.FirstOrDefault(x => x.ID == model.FromID && x.AccountType == (int)EnumUserType.Admin);

            if (teacher != null && admin != null)
            {
                LessonDetail detail = Services.LessonDetail.Insert(new LessonDetail {
                    Description = model.Description, Minitues = model.Minitues, Subject = model.Subject
                });

                Lesson _model = new Lesson();
                _model.Name           = model.Name;
                _model.StartDate      = model.StartDate;
                _model.TeacherID      = model.TeacherID;
                _model.LessonDetailID = detail.ID;
                return(Services.Lesson.Insert(_model));
            }
            else
            {
                return(new Lesson());
            }
        }
        public JsonResult GetById(int id)
        {
            LessonVM lessonVM = null;
            var      client   = new HttpClient
            {
                BaseAddress = new Uri("http://localhost:12280/api/")
            };
            var responseTask = client.GetAsync("Lesson/" + id);

            responseTask.Wait();
            var result = responseTask.Result;

            if (result.IsSuccessStatusCode)
            {
                var readTask = result.Content.ReadAsAsync <LessonVM>();
                readTask.Wait();
                lessonVM = readTask.Result;
            }
            else
            {
                // try to find something
            }
            return(Json(lessonVM, JsonRequestBehavior.AllowGet));
        }
예제 #8
0
        public ActionResult UpdateLessons(LessonVM model)
        {
            using (var MyService = new ServiceReference.Service1Client())
            {
                if (model.VizeTahmin <= model.Vize)
                {
                    model.VizeDurum = "Başarılı";
                }
                if (model.VizeTahmin > model.Vize)
                {
                    model.VizeDurum = "Başarısız";
                }
                if (model.FinalTahmin <= model.Final)
                {
                    model.FinalDurum = "Başarılı";
                }
                if (model.FinalTahmin > model.Final)
                {
                    model.FinalDurum = "Başarısız";
                }
                if (model.FinalTahmin == 0)
                {
                    model.FinalDurum = "";
                }
                if (model.Final == 0)
                {
                    model.FinalDurum = "";
                }
                if (model.VizeTahmin == 0)
                {
                    model.VizeDurum = "";
                }
                if (model.Vize == 0)
                {
                    model.VizeDurum = "";
                }
                if (model.Vize >= 0 & model.Vize <= 100 & model.VizeTahmin >= 0 & model.VizeTahmin <= 100 & model.Final >= 0 & model.Final <= 100 & model.FinalTahmin >= 0 & model.FinalTahmin <= 100 & model.Büt >= 0 & model.Büt <= 100 & model.BütTahmin >= 0 & model.BütTahmin <= 100 & model.GecmeNotu >= 35 & model.GecmeNotu <= 100)
                {
                    if (model.GecmeNotu == 60 & model.Vize != 0)
                    {
                        model.GecerNot = (model.GecmeNotu - (Convert.ToDouble(model.Vize) * 0.4)) / 0.6;
                        model.GecerNot = Math.Round(model.GecerNot, 2);
                        if (model.GecerNot <= 50)
                        {
                            model.GecerNot = 50;
                        }
                    }
                    else if (model.Vize != 0)
                    {
                        model.GecerNot = (model.GecmeNotu - (Convert.ToDouble(model.Vize) * 0.4)) / 0.6;
                        model.GecerNot = Math.Round(model.GecerNot, 2);
                        if (model.GecerNot <= 35)
                        {
                            model.GecerNot = 35;
                        }
                    }
                    MyService.UpdateLesson(new ServiceReference.Lesson {
                        Id = model.Id, Adi = model.Adı, Büt = model.Büt, BütTahmin = model.BütTahmin, Final = model.Final, FinalDurum = model.FinalDurum, FinalTahmin = model.FinalTahmin, Vize = model.Vize, VizeDurum = model.VizeDurum, VizeTahmin = model.VizeTahmin, GecmeNotu = model.GecmeNotu, GecerNot = model.GecerNot
                    }, Convert.ToInt32(Session["UserId"]));
                }


                else
                {
                    TempData["Aralik"] = "*Notların Puan Aralıkları 0 ile 100 arasında olmalıdır veya Geçer Not 35'ten bütük olmalıdır.";
                }
            }
            return(Json(true));
        }