//[ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = "ServiceId,ServiceName,Status,RowStatus,CreatedDate,UpdatedDate")] Service service) { if (ModelState.IsValid) { db.Services.Add(service); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(service)); }
//[ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = "StaticPageId,PageTitle,PageContent,PageType,CreatedDate,UpdatedDate")] StaticPage staticPage) { if (ModelState.IsValid) { db.StaticPages.Add(staticPage); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(staticPage)); }
// GET: Jobs/Create //public ActionResult Create() //{ // ViewBag.LocationId = new SelectList(db.JobLocations, "JobLocationId", "JobLocationName"); // ViewBag.PriceId = new SelectList(db.JobPrices, "JobPriceId", "RowStatus"); // ViewBag.TimeId = new SelectList(db.JobTimes, "JobTimeId", "JobTimeId"); // return View(); //} //// POST: Jobs/Create //// To protect from overposting attacks, please enable the specific properties you want to bind to, for //// more details see http://go.microsoft.com/fwlink/?LinkId=317598. //[HttpPost] //public ActionResult Create([Bind(Include = "JobId,CreatedUserId,JobTiltle,JobDescription,JobType,HelperType,LocationId,TimeId,PriceId,Status,RowStatus,CreatedDate,ExpiryDate,UpdatedDate")] Job job) //{ // if (ModelState.IsValid) // { // db.Jobs.Add(job); // db.SaveChanges(); // return RedirectToAction("Index"); // } // ViewBag.LocationId = new SelectList(db.JobLocations, "JobLocationId", "JobLocationName", job.LocationId); // ViewBag.PriceId = new SelectList(db.JobPrices, "JobPriceId", "RowStatus", job.PriceId); // ViewBag.TimeId = new SelectList(db.JobTimes, "JobTimeId", "JobTimeId", job.TimeId); // return View(job); //} // GET: Jobs/Edit/5 //public ActionResult Edit(int? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // Job job = db.Jobs.Find(id); // if (job == null) // { // return HttpNotFound(); // } // ViewBag.LocationId = new SelectList(db.JobLocations, "JobLocationId", "JobLocationName", job.LocationId); // ViewBag.PriceId = new SelectList(db.JobPrices, "JobPriceId", "RowStatus", job.PriceId); // ViewBag.TimeId = new SelectList(db.JobTimes, "JobTimeId", "JobTimeId", job.TimeId); // return View(job); //} //// POST: Jobs/Edit/5 //// To protect from overposting attacks, please enable the specific properties you want to bind to, for //// more details see http://go.microsoft.com/fwlink/?LinkId=317598. //[HttpPost] //public ActionResult Edit([Bind(Include = "JobId,CreatedUserId,JobTiltle,JobDescription,JobType,HelperType,LocationId,TimeId,PriceId,Status,RowStatus,CreatedDate,ExpiryDate,UpdatedDate")] Job job) //{ // if (ModelState.IsValid) // { // db.Entry(job).State = EntityState.Modified; // db.SaveChanges(); // return RedirectToAction("Index"); // } // ViewBag.LocationId = new SelectList(db.JobLocations, "JobLocationId", "JobLocationName", job.LocationId); // ViewBag.PriceId = new SelectList(db.JobPrices, "JobPriceId", "RowStatus", job.PriceId); // ViewBag.TimeId = new SelectList(db.JobTimes, "JobTimeId", "JobTimeId", job.TimeId); // return View(job); //} // GET: Jobs/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Job job = db.Jobs.Find(id); db.Jobs.Remove(job); db.SaveChanges(); if (job == null) { return(HttpNotFound()); } return(RedirectToAction("Index")); }
public ActionResult Save(AspNetUser model) { if (ModelState.IsValid) { try { he.AspNetUsers.Add(model); he.SaveChanges(); } catch (Exception ex) { TempData["Failure"] = ex; throw; } } else { TempData["Failure"] = "Record Not Saved"; } return(RedirectToAction("Index")); }
public ActionResult Update(AspNetUser objAspNetUser) { AspNetUser Obj = new AspNetUser(); if (Session["UserName"] != null) { string Id = Session["UserName"].ToString(); Obj = he.AspNetUsers.Where(x => x.UserName == Id).FirstOrDefault(); Obj.Email = objAspNetUser.Email; Obj.UserName = objAspNetUser.UserName; he.AspNetUsers.Attach(Obj); he.Entry(Obj).State = EntityState.Modified; he.SaveChanges(); Session.Remove("UserName"); return(View(Obj)); } else { return(RedirectToAction("Login", "Account")); } }