public ActionResult Edit(Guid?id) { SelectListItem defaultselect = new SelectListItem { Text = General.Select, Value = "0" }; var school = new SchoolRepository().Get().Select(x => new SelectListItem { Text = x.SchoolName, Value = x.Id + "" }).ToList(); school.Insert(0, defaultselect); ViewBag.school = school; var session = new SessionRepository().Get().Select(x => new SelectListItem { Text = x.ProgramName, Value = x.Id + "" }).ToList(); session.Insert(0, defaultselect); ViewBag.session = session; orientation_training otModel = null; if (id == null) { otModel = new orientation_training(); } else { var otRepo = new OTRepository(); otModel = otRepo.GetByRowId(id.Value); } return(View(otModel)); }
// GET: OT public ActionResult Index(string sortOrder, string filter, string archived, int page = 1) { ViewBag.searchQuery = string.IsNullOrEmpty(filter) ? "" : filter; ViewBag.showArchived = (archived ?? "") == "on"; page = page > 0 ? page : 1; int pageSize = 0; pageSize = pageSize > 0 ? pageSize : 10; ViewBag.CurrentSort = sortOrder; IEnumerable <orientation_training> ots; var repository = new OTRepository(); if (string.IsNullOrEmpty(filter)) { ots = repository.Get(); } else { ots = repository.Get().Where(x => x.Subject.Contains(filter)); } //Sorting order ots = ots.OrderByDescending(x => x.CreatedAt); ViewBag.Count = ots.Count(); return(View(ots.ToPagedList(page, pageSize))); }
public ActionResult Delete(int id) { var repository = new OTRepository(); repository.Delete(id); return(RedirectToAction("Index")); }
public ActionResult Edit(volunteer_profile volunteer) { var repository = new VolunteerRepository(); var oVolunteer = repository.GetbyGuid(volunteer.RowGuid); var cu = Session["user"] as ContextUser; if (volunteer.SubmitButton == "reject") { oVolunteer.IsRejected = true; oVolunteer.RejectedBy = cu.OUser.Username; oVolunteer.ApprovedAtLevel1Comments = volunteer.ApprovedAtLevel1Comments; oVolunteer.ApprovedAtLevel2Comments = volunteer.ApprovedAtLevel2Comments; oVolunteer.ApprovedAtLevel3Comments = volunteer.ApprovedAtLevel3Comments; repository.Put(oVolunteer.Id, oVolunteer); return(RedirectToAction("Index")); } if (volunteer.SubmitButton == "otdate") { // oVolunteer.OTDateTime = DateTime.Parse(volunteer.OTDateString); oVolunteer.OTId = volunteer.OTId; oVolunteer.OTIdAssigner = cu.OUser.Id; repository.Put(oVolunteer.Id, oVolunteer); return(RedirectToAction("Index", new { status = "approved" })); } if (volunteer.SubmitButton == "accept") { //todo: send notification to super admin if (oVolunteer.OTIdAssigner != null) { var ot = new OTRepository().Get(oVolunteer.OTId.Value); var admin = new AccountRepository().Get(oVolunteer.OTIdAssigner.Value); var bogusController = Util.CreateController <EmailTemplateController>(); EmailTemplateModel emodel = new EmailTemplateModel { Title = "Injaz: accepted by volunteer.", VolunteerName = oVolunteer.VolunteerName, User = admin.FirstName, OTSubject = ot.Subject }; string body = Util.RenderViewToString(bogusController.ControllerContext, "VolunteerAcceptsOT", emodel); EmailSender.SendSupportEmail(body, admin.Email); } oVolunteer.OTAcceptedByVolunteer = volunteer.OTAcceptedByVolunteer; repository.Put(oVolunteer.Id, oVolunteer); return(RedirectToAction("Edit", oVolunteer.RowGuid)); } if (volunteer.SubmitButton == "otattendense") { oVolunteer.OTAttendenceForVolunteer = volunteer.OTAttendenceForVolunteer; repository.Put(oVolunteer.Id, oVolunteer); return(RedirectToAction("Index", new { status = "approved" })); } ApprovedBylevel(volunteer, repository, oVolunteer, cu); return(RedirectToAction("Index")); }
public ActionResult Edit(Guid id) { var repository = new VolunteerRepository(); var volunteer = repository.GetbyGuid(id); volunteer.OTDateString = volunteer.OTDateTime != null?volunteer.OTDateTime.Value.ToShortDateString() : null; var Ots = new OTRepository().Get().Select(x => new SelectListItem { Text = x.Subject + " - " + (x.OTDateTime != null ? x.OTDateTime.Value.ToShortDateString() : null), Value = x.Id + "" }).ToList(); ViewBag.Otsdd = Ots; return(View(volunteer)); }
public ActionResult Edit(orientation_training profile) { var otRepo = new OTRepository(); orientation_training ot = null; var cu = Session["user"] as ContextUser; if (profile.Id == 0) { ot = new orientation_training(); ot.RowGuid = Guid.NewGuid(); ot.CreatedAt = DateTime.Now; ot.CreatedBy = cu.OUser.Id; } else { ot = otRepo.Get(profile.Id); ot.UpdatedAt = DateTime.Now; ot.UpdatedBy = cu.OUser.Id; } ot.Location = profile.Location; ot.Subject = profile.Subject; ot.OTDateTime = profile.OTDateTime; ot.ContactPersonName = profile.ContactPersonName; ot.ContactPersonPhone = profile.ContactPersonPhone; ot.SchoolId = profile.SchoolId == 0 ? null : profile.SchoolId; ot.SessionId = profile.SessionId == 0 ? null : profile.SessionId; if (profile.Id == 0) { otRepo.Post(ot); } else { otRepo.Put(ot.Id, ot); } return(RedirectToAction("Index")); }