public FacultyModel AddFaculty(FacultyModel facultyModel) { var resultSP = DB.AddFaculty(facultyModel.facultyCode, facultyModel.facultyName, facultyModel.facultyHead).Select(f => new FacultyModel { facultyCode = f.facultyCode, facultyHead = f.facultyHead, facultyName = f.facultyName }); if (GlobalVariable.queryType == 0) { FACULTY faculty = new FACULTY { facultyCode = facultyModel.facultyCode, facultyHead = facultyModel.facultyHead, facultyName = facultyModel.facultyName }; DB.FACULTYS.Add(faculty); DB.SaveChanges(); return(GetOneFacultyByCode(faculty.facultyCode)); } else { return(resultSP.SingleOrDefault()); } }
public FacultyModel UpdateFaculty(FacultyModel facultyModel) { var resultSP = DB.UpdateFaculty(facultyModel.facultyCode, facultyModel.facultyName, facultyModel.facultyHead).Select(f => new FacultyModel { facultyCode = f.facultyCode, facultyHead = f.facultyHead, facultyName = f.facultyName }); if (GlobalVariable.queryType == 0) { FACULTY faculty = DB.FACULTYS.Where(f => f.facultyCode.Equals(facultyModel.facultyCode)).SingleOrDefault(); if (faculty == null) { return(null); } faculty.facultyCode = facultyModel.facultyCode; faculty.facultyHead = facultyModel.facultyHead; faculty.facultyName = facultyModel.facultyName; DB.SaveChanges(); return(GetOneFacultyByCode(faculty.facultyCode)); } else { return(resultSP.SingleOrDefault()); } }
public ActionResult UpdateFaculty(FACULTY faculties, HttpPostedFileBase postedFile) { int facultiesId = faculties.Id; FACULTY faculty = ManageStudent.FACULTies.SingleOrDefault(u => u.Id == facultiesId && u.Status == false); if (ModelState.IsValid) { if (SaveImage(postedFile)) { if (postedFile != null) { faculty.Avatar = "images/" + postedFile.FileName; } faculty.FirstName = faculties.FirstName; faculty.LastName = faculties.LastName; faculty.Profiles = faculties.Profiles; faculty.Birthday = faculties.Birthday; faculty.Address = faculties.Address; faculty.Gender = faculties.Gender; ManageStudent.SaveChanges(); ViewBag.Status = "Update " + faculties.LastName + " successful !!!"; } else { ViewBag.Status = "Update " + faculties.LastName + " failed !!!"; } } List <FACULTY> fac = ManageStudent.FACULTies.Where(u => u.Status == false).ToList <FACULTY>(); return(View("Faculty", fac)); }
//public List<FACULTY> GetFacultEmployees(int id) //{ // return db.FACULTies.Where(c => c.EmployeeId == id).ToList(); //} /// <summary> /// Add a new Faculty /// </summary> /// <param name="Faculty">The Faculty to add</param> /// <returns>True if Faculty is added successfuly otherwise false</returns> public bool AddFaculty(FACULTY faculty) { if (faculty != null) { db.FACULTies.Add(faculty); db.SaveChanges(); return(true); } return(false); }
public ActionResult Edit(FACULTY fACULTY) { if (new FacultyDAO().Edit(fACULTY)) { SetAlert("Successfully edited!", "success"); } else { SetAlert("Editing failed, please try again!", "warning"); } return(RedirectToAction("Index", "Faculty")); }
public void Delete(long id) { using (ctx = new ReadingRoomsEntities()) { FACULTY entity = ctx.FACULTies.Where(f => f.FAC_ID == id).FirstOrDefault(); if (CheckHelper.IsFilled(entity)) { ctx.FACULTies.Remove(entity); ctx.SaveChanges(); } } }
public ActionResult Create(FACULTY fACULTY) { if (new FacultyDAO().Create(fACULTY)) { SetAlert("Added successfully!", "success"); } else { SetAlert("Add failed, please try again!", "warning"); } return(RedirectToAction("Index", "Faculty")); }
public FACULTY Update(FACULTY entity) { FACULTY updatedFaculty = null; using (ctx = new ReadingRoomsEntities()) { updatedFaculty = ctx.FACULTies.Attach(entity); ctx.Entry(entity).State = EntityState.Modified; ctx.SaveChanges(); } return(updatedFaculty); }
public bool Edit(FACULTY fACULTy) { try { var data = db.FACULTies.Find(fACULTy.FACULTY_Id); data.FACULTY_Code = GetCode(fACULTy.FACULTY_Name).ToUpper(); data.FACULTY_Name = fACULTy.FACULTY_Name; data.FACULTY_Descriptions = fACULTy.FACULTY_Descriptions; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool Create(FACULTY fACULTy) { try { Guid id = Guid.NewGuid(); fACULTy.FACULTY_Id = id; fACULTy.FACULTY_Code = GetCode(fACULTy.FACULTY_Name).ToUpper(); db.FACULTies.Add(fACULTy); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public List <BlogDTO> GetBlogs(long facId) { FACULTY faculty = null; List <BlogDTO> retVal = null; BlogTransformer blogTransformer; // TODO : Implementirati metodu za dobavljanje blogova koji pripadaju fakultetu sa prosledjenim ID. //faculty = facultyRepository.GetById(facId); blogTransformer = new BlogTransformer(); if (CheckHelper.IsFilled(faculty) && CheckHelper.IsFilled(faculty.BLOGs)) { retVal = blogTransformer.TransformToDTO(faculty.BLOGs.ToList()); } return(retVal); }
public List <ReadingRoomDTO> GetReadingRooms(long facId) { FACULTY faculty = null; List <ReadingRoomDTO> retVal = null; ReadingRoomTransformer rroomTransformer; List <READING_ROOM> rrooms; rrooms = rroomRepository.GetRRoomsForFaculty(facId); rroomTransformer = new ReadingRoomTransformer(); if (CheckHelper.IsFilled(rrooms)) { retVal = rroomTransformer.TransformToDTO(rrooms); } return(retVal); }
public FACULTY GetById(long id) { FACULTY faculty = null; using (ctx = new ReadingRoomsEntities()) { if (id > 0) { faculty = ctx.FACULTies .Where(f => f.FAC_ID == id) .Include(f => f.UNIVERSITY) .FirstOrDefault(); } } return(faculty); }
public ActionResult AddFaculty(FACULTY faculty, HttpPostedFileBase PostedFile) { if (SaveImage(PostedFile)) { faculty.Avatar = "images/" + PostedFile.FileName; faculty.Status = false; ManageStudent.FACULTies.Add(faculty); ManageStudent.SaveChanges(); ViewBag.Status = "Add Faculty " + faculty.LastName + " successful !!!"; } else { ViewBag.Status = "Add Faculty " + faculty.LastName + " failed !!!"; } List <FACULTY> fac = ManageStudent.FACULTies.Where(u => u.Status == false).ToList <FACULTY>(); return(View("Faculty", fac)); }
public int DeleteFaculty(string facultyCode) { var resultSP = DB.DeleteFaculty(facultyCode); if (GlobalVariable.queryType == 0) { FACULTY faculty = DB.FACULTYS.Where(f => f.facultyCode.Equals(facultyCode)).SingleOrDefault(); DB.FACULTYS.Attach(faculty); if (faculty == null) { return(0); } DB.FACULTYS.Remove(faculty); DB.SaveChanges(); return(1); } else { return(resultSP); } }
public FACULTY Add(FACULTY entity) { FACULTY insertedFaculty = null; if (CheckHelper.IsFilled(entity)) { using (ctx = new ReadingRoomsEntities()) { entity.FAC_ID = 1; FACULTY maxFaculty = ctx.FACULTies.OrderByDescending(f => f.FAC_ID).FirstOrDefault(); if (CheckHelper.IsFilled(maxFaculty)) { entity.FAC_ID = maxFaculty.FAC_ID + 1; } insertedFaculty = ctx.FACULTies.Add(entity); ctx.SaveChanges(); } } return(insertedFaculty); }
/// <summary> /// Update a faculty /// </summary> /// <param name="faculty">faculty object</param> public void EditFaculty(FACULTY faculty) { // Change the state of the faculty object to modified, so it will be update in database db.Entry(faculty).State = EntityState.Modified; db.SaveChanges(); }