public ActionResult CreateResource(string resourceName) { if (!User.Identity.IsAuthenticated) return View("NotLogged"); var model = new CreateResourceModel(); model.Name = resourceName; return View("CreateResource", model); }
public ActionResult SaveNewResource(CreateResourceModel model) { if (!User.Identity.IsAuthenticated) return View("NotLogged"); model.Description = HttpUtility.HtmlDecode(model.Description); Resource res; using (var session = new RBEPortalServer.RBEPortalContext()) { var userId = session.RBEPortalData.Users.Where(o => o.LoweredUserName == User.Identity.Name.ToLower()).Select(o => o.UserId).Single(); res = new Resource { ResourceId = Guid.NewGuid(), Name = model.Name, Description = model.Description, Status = "active", CreationDate = DateTime.Now, ModifiedDate = DateTime.Now, ModifiedBy = userId, }; session.RBEPortalData.Resources.Add(res); session.RBEPortalData.SaveChanges(); } return DisplayResource(res.ResourceId); }