コード例 #1
0
 public ActionResult StudentRead()
 {
     try
     {
         return(ActionResultProcess.Success(studentService.Read().Select(x => AutoMapper.Mapper.Map <StudentViewModel>(x)).ToList()));
     }
     catch (Exception ex)
     {
         return(ActionResultProcess.Error(ex));
     }
 }
コード例 #2
0
 public ActionResult AddStudentSubject(int studentId, List <int> subjectId)
 {
     try
     {
         studentSubjectService.Create(studentId, subjectId);
         return(ActionResultProcess.Success());
     }
     catch (Exception ex)
     {
         return(ActionResultProcess.Error(ex));
     }
 }
コード例 #3
0
 public ActionResult StudentDelete(StudentViewModel item)
 {
     try
     {
         studentService.Delete(item.StudentId);
         studentMoreService.Delete(item.StudentId);
         return(ActionResultProcess.Success());
     }
     catch (Exception ex)
     {
         return(ActionResultProcess.Error(ex));
     }
 }
コード例 #4
0
 public ActionResult StudentUpdate(StudentViewViewModel item)
 {
     try
     {
         studentService.Update(Mapper.Map <Student>(item.Student), item.Student.StudentId);
         studentMoreService.Update(Mapper.Map <StudentMore>(item.StudentMore), item.Student.StudentId);
         return(ActionResultProcess.Success());
     }
     catch (Exception ex)
     {
         return(ActionResultProcess.Error(ex));
     }
 }
コード例 #5
0
 public ActionResult StudentSubjectList(int studentId)
 {
     try
     {
         return(ActionResultProcess.Success(studentSubjectService.Read(new Student {
             StudentId = studentId
         }).Select(x => AutoMapper.Mapper.Map <StudentSubjectViewModel>(x)).ToList()));
     }
     catch (Exception ex)
     {
         return(ActionResultProcess.Error(ex));
     }
 }
コード例 #6
0
 public ActionResult SubjectDelete(int id)
 {
     try
     {
         subjectService.Delete(id);
         subjectModuleServivice.Delete(id);
         return(ActionResultProcess.Success());
     }
     catch (Exception ex)
     {
         return(ActionResultProcess.Error(ex));
     }
 }
コード例 #7
0
 public ActionResult StudentCreate(StudentViewViewModel item)
 {
     try
     {
         Student s = studentService.Create(Mapper.Map <Student>(item.Student));
         StudentMoreViewModel studentMore = item.StudentMore;
         studentMore.StudentId = s.StudentId;
         studentMoreService.Create(Mapper.Map <StudentMore>(item.StudentMore));
         return(ActionResultProcess.Success());
     }
     catch (Exception ex)
     {
         return(ActionResultProcess.Error(ex));
     }
 }
コード例 #8
0
        public ActionResult StudentReadSingle(int id)
        {
            try
            {
                var result = new StudentViewViewModel()
                {
                    Student     = Mapper.Map <StudentViewModel>(studentService.Read(id)),
                    StudentMore = Mapper.Map <StudentMoreViewModel>(studentMoreService.Read(id))
                };

                return(ActionResultProcess.Success(result));
            }
            catch (Exception ex)
            {
                return(ActionResultProcess.Error(ex));
            }
        }
コード例 #9
0
        public ActionResult SubjectReadSingle(int id)
        {
            try
            {
                var result = new SubjectViewViewModel()
                {
                    subjectVieModel   = Mapper.Map <SubjectViewModel>(subjectService.Read(id)),
                    subjectModuleList = subjectModuleServivice.Read(id)
                };

                return(ActionResultProcess.Success(result));
            }
            catch (Exception ex)
            {
                return(ActionResultProcess.Error(ex));
            }
        }
コード例 #10
0
 public ActionResult StudentUpdate(SubjectViewViewModel item)
 {
     try
     {
         subjectService.Update(Mapper.Map <Subject>(item.subjectVieModel), item.subjectVieModel.SubjectId);
         List <string> subjectModuleNames = item.subjectModuleList;
         var           subjectModuleList  = new List <SubjectModules>();
         foreach (var val in subjectModuleNames)
         {
             subjectModuleList.Add(new SubjectModules {
                 ModuleName = val, SubjectId = item.subjectVieModel.SubjectId
             });
         }
         subjectModuleServivice.Update(subjectModuleList, item.subjectVieModel.SubjectId);
         return(ActionResultProcess.Success());
     }
     catch (Exception ex)
     {
         return(ActionResultProcess.Error(ex));
     }
 }
コード例 #11
0
 public ActionResult FileUpload(IEnumerable <HttpPostedFileBase> files)
 {
     try
     {
         if (files != null)
         {
             var    file = files.FirstOrDefault();
             string pic  = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(file.FileName);
             string path = System.IO.Path.Combine(
                 HttpContext.Current.Server.MapPath("~/images/profile"), pic);
             file.SaveAs(path);
             return(ActionResultProcess.Success(pic));
         }
         else
         {
             throw new ObjectNotFoundException("image not founded");
         }
     }
     catch (Exception ex)
     {
         return(ActionResultProcess.Error(ex));
     }
 }
コード例 #12
0
        public ActionResult SubjectCreate(SubjectViewViewModel item)
        {
            var dto = HttpContext.Current.Request.Form["item"];

            try
            {
                Subject       s = subjectService.Create(Mapper.Map <Subject>(item.subjectVieModel));
                List <string> subjectModuleNames = item.subjectModuleList;
                var           subjectModuleList  = new List <SubjectModules>();
                foreach (var val in subjectModuleNames)
                {
                    subjectModuleList.Add(new SubjectModules {
                        ModuleName = val, SubjectId = item.subjectVieModel.SubjectId
                    });
                }
                subjectModuleServivice.Create(subjectModuleList);
                return(ActionResultProcess.Success());
            }
            catch (Exception ex)
            {
                return(ActionResultProcess.Error(ex));
            }
        }