示例#1
0
        public ActionResult SaveResource(EditResourceModel model)
        {
            if (!User.Identity.IsAuthenticated)
                return View("NotLogged");

            model.Description = HttpUtility.HtmlDecode(model.Description);

            using (var session = new RBEPortalServer.RBEPortalContext()) {
                var userId = session.RBEPortalData.Users.Where(o => o.LoweredUserName == User.Identity.Name.ToLower()).Select(o => o.UserId).Single();
                var resource = session.RBEPortalData.Resources.Single(o => o.ResourceId == model.Id);

                resource.Name = model.Name;
                resource.Description = model.Description;
                resource.ModifiedDate = DateTime.Now;
                resource.ModifiedBy = userId;

                //session.RBEPortalData.Resources.Add(res);
                session.RBEPortalData.SaveChanges();
            }

            return DisplayResource(model.Id);
        }
示例#2
0
        public ActionResult EditResource(Guid resourceId)
        {
            var model = new EditResourceModel();
            model.Id = resourceId;

            using (var session = new RBEPortalServer.RBEPortalContext()) {
                var resource = session.RBEPortalData.Resources.Single(o => o.ResourceId == resourceId);
                model.Name = resource.Name;
                model.Description = resource.Description;
            }

            return View("EditResource", model);
        }