public async Task <IHttpActionResult> PostPromotionLocation(PromotionLocation promotionLocation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.PromotionLocations.Add(promotionLocation); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (PromotionLocationExists(promotionLocation.id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = promotionLocation.id }, promotionLocation)); }
public async Task <IHttpActionResult> PutPromotionLocation(Guid id, PromotionLocation promotionLocation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != promotionLocation.id) { return(BadRequest()); } db.Entry(promotionLocation).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PromotionLocationExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteConfirmed(Guid id) { PromotionLocation promotionLocation = db.PromotionLocations.Find(id); db.PromotionLocations.Remove(promotionLocation); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "id,adviserId,cityId,locationAddress,latitude,longitude,effectiveDate,effectiveTime,expireDate,expireTime,description")] PromotionLocation promotionLocation) { if (ModelState.IsValid) { db.Entry(promotionLocation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.adviserId = new SelectList(db.Advisers, "adviserId", "fullName", promotionLocation.adviserId); return(View(promotionLocation)); }
public async Task <IHttpActionResult> GetPromotionLocation(Guid id) { PromotionLocation promotionLocation = await db.PromotionLocations.FindAsync(id); if (promotionLocation == null) { return(NotFound()); } return(Ok(promotionLocation)); }
// GET: PromotionLocations/Details/5 public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PromotionLocation promotionLocation = db.PromotionLocations.Find(id); if (promotionLocation == null) { return(HttpNotFound()); } return(View(promotionLocation)); }
public async Task <IHttpActionResult> DeletePromotionLocation(Guid id) { PromotionLocation promotionLocation = await db.PromotionLocations.FindAsync(id); if (promotionLocation == null) { return(NotFound()); } db.PromotionLocations.Remove(promotionLocation); await db.SaveChangesAsync(); return(Ok(promotionLocation)); }
// GET: PromotionLocations/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PromotionLocation promotionLocation = db.PromotionLocations.Find(id); if (promotionLocation == null) { return(HttpNotFound()); } ViewBag.adviserId = new SelectList(db.Advisers, "adviserId", "fullName", promotionLocation.adviserId); ViewBag.cityId = new SelectList(db.Cities, "cityId", "name", promotionLocation.cityId); return(View(promotionLocation)); }
public ActionResult Create([Bind(Include = "promotionLocationId,adviserId, cityId, locationAddress, effectiveDate,effectiveTime,expireDate,expireTime,description")] PromotionLocation promotionLocation) { if (ModelState.IsValid) { promotionLocation.id = Guid.NewGuid(); db.PromotionLocationInsert(promotionLocation.adviserId, promotionLocation.cityId, promotionLocation.locationAddress, promotionLocation.latitude, promotionLocation.longitude, promotionLocation.effectiveDate, promotionLocation.expireDate, promotionLocation.effectiveTime, promotionLocation.expireTime, promotionLocation.description); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.adviserId = new SelectList(db.Advisers, "adviserId", "fullName", promotionLocation.adviserId); ViewBag.cityId = new SelectList(db.Cities, "cityId", "name", promotionLocation.cityId); return(View(promotionLocation)); }