예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            PromotionLocation promotionLocation = db.PromotionLocations.Find(id);

            db.PromotionLocations.Remove(promotionLocation);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #4
0
 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));
 }
예제 #5
0
        public async Task <IHttpActionResult> GetPromotionLocation(Guid id)
        {
            PromotionLocation promotionLocation = await db.PromotionLocations.FindAsync(id);

            if (promotionLocation == null)
            {
                return(NotFound());
            }

            return(Ok(promotionLocation));
        }
예제 #6
0
        // 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));
        }
예제 #7
0
        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));
        }
예제 #8
0
        // 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));
        }
예제 #9
0
        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));
        }