public ActionResult AddRandomUri(Guid userContractId, string uri) { if (userContractId == null) { return BreadCrum.RedirectToPreviousAction(Session, ControllerName); } var userContract = db.UserContracts.Find(userContractId); var userContractUri = new UserContractUri() { Id = Guid.NewGuid(), UserContractId = userContract.Id, Uri = uri, Name = "noname", Enabled = false, RandomFunction = 0, }; userContract.UserContractUris.Add(userContractUri); var randomUri = new RandomUri() { Id = Guid.NewGuid(), Uri = uri, UserContractUriId = userContractUri.Id, RandomParameter = 1, }; userContractUri.RandomUris.Add(randomUri); db.SaveChanges(); return RedirectToAction("Edit", new {id = userContract.Id}); }
// // GET: /RandomUri/Create public ActionResult Create(Guid? contractUriId) { if (contractUriId.HasValue) { ViewBag.UserContractUriId = new SelectList(db.UserContractUris, "Id", "Uri", contractUriId); var model = new RandomUri() { UserContractUriId = contractUriId.Value }; return View(model); } return BreadCrum.RedirectToPreviousAction(Session, ControllerName); }
public ActionResult Create(RandomUri randomuri, Guid contractUriId) { ViewBag.ContractUriId = contractUriId; var contractUri = db.UserContractUris.SingleOrDefault(row => row.Id == contractUriId); ViewBag.ContractUri = contractUri; if (ModelState.IsValid) { randomuri.Id = Guid.NewGuid(); db.RandomUris.Add(randomuri); try { db.SaveChanges(); } catch (DbEntityValidationException ex) { } //return RedirectToAction("Edit", "ContractUri", new { Id = contractUriId, contractId = contractUri.Id }); return BreadCrum.RedirectToPreviousAction(Session, ControllerName); } ViewBag.UserContractUriId = new SelectList(db.UserContractUris.Where(row => row.Id == contractUriId), "Id", "Uri", randomuri.UserContractUriId); return View(randomuri); }
public ActionResult Edit(RandomUri randomuri) { if (ModelState.IsValid) { db.Entry(randomuri).State = EntityState.Modified; db.SaveChanges(); //return RedirectToAction("Edit", "ContractUri", new { Id = randomuri.UserContractUriId, contractId = randomuri.UserContractUri.UserContractId }); return BreadCrum.RedirectToPreviousAction(Session, ControllerName); } ViewBag.UserContractUriId = new SelectList(db.UserContractUris.Where(row => row.Id == randomuri.UserContractUriId), "Id", "Uri", randomuri.UserContractUriId); return View(randomuri); }
private void BuildRecipeByRandom4(UserContract userContract) { var userContractUri = new UserContractUri() { Id = Guid.NewGuid(), UserContractId = userContract.Id, Uri = userContract.Uri, Name = "noname", Enabled = false, RandomFunction = 3, }; userContract.UserContractUris.Add(userContractUri); var userContractRedirect = new UserContractRedirect { Id = Guid.NewGuid(), UserContractUri = userContractUri.Id, Enabled = true, DateTimeValueStart = userContract.StartDate, DateTimeValueStop = userContract.EndDate }; userContractUri.UserContractRedirects.Add(userContractRedirect); var randomUri = new RandomUri() { Id = Guid.NewGuid(), Uri = userContract.Uri, UserContractUriId = userContractUri.Id, RandomParameter = 1, }; userContractUri.RandomUris.Add(randomUri); }