public ActionResult GetSocialLifeSkill()
        {
            var school = (T_DM_Truong)Session[Constant.SCHOOL_SESSION];

            if (school == null)
            {
                return(RedirectToRoute("login"));
            }
            using (var social = new SocialLifeSkillService())
            {
                ViewBag.Socials = social.GetSocialLifeSkillsBySchoolId(school.SchoolID);
            }
            return(View());
        }
 public ActionResult GetDetail(int id)
 {
     using (var social = new SocialLifeSkillService())
     {
         var socialDetail     = social.GetSocialLifeSkillsById(id);
         var socialDetailJson = JsonConvert.SerializeObject(socialDetail,
                                                            Formatting.None,
                                                            new JsonSerializerSettings()
         {
             ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
         });
         return(Json(new ReturnFormat(200, "success", socialDetailJson), JsonRequestBehavior.AllowGet));
     }
 }
        public async Task <ActionResult> ExportSocialLifeSkill(DateTime dateFrom, DateTime dateTo)
        {
            Account account = (Account)Session[Utils.Constant.MANAGER_SESSION];

            if (account == null)
            {
                return(RedirectToRoute("login"));
            }
            using (var social = new SocialLifeSkillService())
            {
                List <SocialLifeSkill> socialLifeSkills = social.GetSocialLifeSkills(dateFrom, dateTo);
                string fileName = string.Concat("ds-kynangsong.xlsx");
                string filePath = System.Web.HttpContext.Current.Server.MapPath("~/Utils/Files/" + fileName);
                await Utils.ExportExcel.GenerateXLSSocialLifeSkill(socialLifeSkills, dateFrom, dateTo, filePath);

                return(File(filePath, "application/vnd.ms-excel", fileName));
            }
        }
        public ActionResult Registration(int id, SocialLifeSkillDTO socialLifeSkillDTO)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new ReturnFormat(400, "failed", null), JsonRequestBehavior.AllowGet));
            }
            var school = (T_DM_Truong)Session[Constant.SCHOOL_SESSION];

            using (var social = new SocialLifeSkillService())
            {
                SocialLifeSkill socialLifeSkill = social.GetSocialLifeSkillsById(id);
                Mapper.Map(socialLifeSkillDTO, socialLifeSkill);
                socialLifeSkill.SchoolName = school.TenTruong;
                socialLifeSkill.CreatedAt  = DateTime.Now;
                socialLifeSkill.SchoolId   = school.SchoolID;
                var inserted = social.UpdateSocialLifeSkills(socialLifeSkill);
                return(Json(new ReturnFormat(200, "success", null), JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult PostFile(HttpPostedFileBase fileKeHoach)
        {
            var school = (T_DM_Truong)Session[Constant.SCHOOL_SESSION];

            if (school == null)
            {
                return(Json(new ReturnFormat(403, "access denied", null), JsonRequestBehavior.AllowGet));
            }
            try
            {
                if (fileKeHoach.ContentLength > 0)
                {
                    using (var social = new SocialLifeSkillService())
                    {
                        string _filekehoach = Path.GetFileName(fileKeHoach.FileName);

                        bool existedFilekehoach = social.CheckExistedFileKeHoach(_filekehoach);
                        if (existedFilekehoach == true)
                        {
                            return(Json(new ReturnFormat(409, "Tên file đã tồn tại. Vui lòng chọn tên khác", null), JsonRequestBehavior.AllowGet));
                        }
                        string _path2 = Path.Combine(Server.MapPath("~/UploadedFiles/SocialSkill"), _filekehoach);
                        fileKeHoach.SaveAs(_path2);
                        SocialLifeSkill socialLifeSkill = new SocialLifeSkill();
                        socialLifeSkill.FileKeHoach = _filekehoach;
                        var inserted = social.CreateSocialLifeSkills(socialLifeSkill);
                        return(Json(new ReturnFormat(200, "success", inserted.Id), JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json(new ReturnFormat(400, "failed", null), JsonRequestBehavior.AllowGet));
                }
            }
            catch
            {
                return(Json(new ReturnFormat(400, "failed", null), JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult SocialLifeskill(DateTime dateFrom, DateTime dateTo)
        {
            var manager = (Account)Session[Constant.MANAGER_SESSION];

            if (manager == null)
            {
                return(RedirectToRoute("quanlylogin"));
            }

            var managerPersmission = (List <UserPermission>)Session[Constant.MANAGER_PERMISSION_SESSION];

            //var permission = 3;
            if (managerPersmission.Where(s => s.PermissionId == 3).FirstOrDefault() == null)
            {
                return(RedirectToRoute("quanlylogin"));
            }
            using (var social = new SocialLifeSkillService())
            {
                ViewBag.Socials = social.GetSocialLifeSkills(dateFrom, dateTo);
            }
            ViewBag.DateFrom = dateFrom.ToString("dd-MM-yyyy");
            ViewBag.DateTo   = dateTo.ToString("dd-MM-yyyy");
            return(View());
        }