Beispiel #1
0
        //
        // GET: /GetRequest/
        public ActionResult GetRequest()
        {
            var id         = Request.QueryString["id"];
            var repo       = new BeverageRequestRepository();
            var bevRequest = repo.LoadByKey(id);

            return(Json(bevRequest, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public ActionResult UpdateStatus()
        {
            var id         = Request.Form.Get("id");
            var status     = Request.Form.Get("status");
            var repo       = new BeverageRequestRepository();
            var bevRequest = repo.LoadByKey(id);

            if (bevRequest != null)
            {
                bevRequest.Status = status;
                repo.Update(bevRequest);
            }
            return(Json(bevRequest));
        }
Beispiel #3
0
        public ActionResult CreateRequest()
        {
            var bevRequest = new BeverageRequest();

            bevRequest.FridgeID      = Request.Form.Get("FridgeID");
            bevRequest.BeverageTitle = Request.Form.Get("BeverageTitle");
            bevRequest.BeerAPIID     = Request.Form.Get("BeerAPIID");
            bevRequest.Status        = BeverageRequest.Statuses.Submitted.ToString();
            bevRequest.RequestDate   = DateTime.Now;
            bevRequest.Email         = HttpContext.User.Identity.Name;

            var repo = new BeverageRequestRepository();

            repo.Save(bevRequest);

            bevRequest = repo.LoadByKey(bevRequest.ID);

            return(Json(bevRequest));
        }
Beispiel #4
0
        public ActionResult DeleteRequest()
        {
            var id         = Request.Form.Get("id");
            var repo       = new BeverageRequestRepository();
            var bevRequest = repo.LoadByKey(id);

            if (bevRequest != null && bevRequest.Email == HttpContext.User.Identity.Name)
            {
                repo.Delete(bevRequest);
                bevRequest = repo.LoadByKey(id);
                if (bevRequest == null)
                {
                    return(Json("success"));
                }
                else
                {
                    return(Json("unknown error"));
                }
            }
            else
            {
                return(Json("user not authorized"));
            }
        }