コード例 #1
0
ファイル: OTController.cs プロジェクト: waqarahmad901/InjazV3
        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));
        }
コード例 #2
0
ファイル: OTController.cs プロジェクト: waqarahmad901/InjazV3
        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"));
        }