Esempio n. 1
0
        // 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)));
        }
Esempio n. 2
0
        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"));
        }