public ActionResult StudentRead()
 {
     try
     {
         return(ActionResultProcess.Success(studentService.Read().Select(x => AutoMapper.Mapper.Map <StudentViewModel>(x)).ToList()));
     }
     catch (Exception ex)
     {
         return(ActionResultProcess.Error(ex));
     }
 }
 public ActionResult AddStudentSubject(int studentId, List <int> subjectId)
 {
     try
     {
         studentSubjectService.Create(studentId, subjectId);
         return(ActionResultProcess.Success());
     }
     catch (Exception ex)
     {
         return(ActionResultProcess.Error(ex));
     }
 }
 public ActionResult StudentDelete(StudentViewModel item)
 {
     try
     {
         studentService.Delete(item.StudentId);
         studentMoreService.Delete(item.StudentId);
         return(ActionResultProcess.Success());
     }
     catch (Exception ex)
     {
         return(ActionResultProcess.Error(ex));
     }
 }
 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));
     }
 }
 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));
     }
 }
Exemple #6
0
 public ActionResult SubjectDelete(int id)
 {
     try
     {
         subjectService.Delete(id);
         subjectModuleServivice.Delete(id);
         return(ActionResultProcess.Success());
     }
     catch (Exception ex)
     {
         return(ActionResultProcess.Error(ex));
     }
 }
 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));
     }
 }
        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));
            }
        }
Exemple #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));
            }
        }
Exemple #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));
     }
 }
 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));
     }
 }
Exemple #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));
            }
        }