public SocialLifeSkill UpdateSocialLifeSkills(SocialLifeSkill socialLifeSkill) { using (var _db = new HoatDongTraiNghiemDB()) { _db.Entry(socialLifeSkill).State = EntityState.Modified; _db.SaveChanges(); return(socialLifeSkill); } }
public SocialLifeSkill CreateSocialLifeSkills(SocialLifeSkill socialLifeSkill) { using (var _db = new HoatDongTraiNghiemDB()) { _db.SocialLifeSkills.Add(socialLifeSkill); _db.SaveChanges(); return(socialLifeSkill); } }
public bool CheckExistedFileKeHoach(string fileKeHoach) { using (var _db = new HoatDongTraiNghiemDB()) { SocialLifeSkill socialLifeSkill = _db.SocialLifeSkills.Where(s => s.FileKeHoach == fileKeHoach).FirstOrDefault(); if (socialLifeSkill == null) { return(false); } return(true); } }
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)); } }