Ejemplo n.º 1
0
        public HttpResponseMessage Get(string type)
        {
            string items = "";

            switch (type)
            {
            case "calendar":
            case "news":
                List <FarmInfoItem> infoItems = InfoItemOps.GetInfoItems(type);
                items = new JavaScriptSerializer().Serialize(infoItems);
                break;

            case "map":
                List <MapItem> mapItems = MapItemOps.GetMapItems("none");
                items = new JavaScriptSerializer().Serialize(mapItems);
                break;

            case "shop":
                List <Product> products = ProductOps.GetProducts();
                items = new JavaScriptSerializer().Serialize(products);
                break;
            }

            var response = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new StringContent(items);

            return(response);
        }
Ejemplo n.º 2
0
        public ActionResult LoadEditItem(int id)
        {
            List <FarmInfoItem> model = new List <FarmInfoItem>();
            FarmInfoItem        item  = InfoItemOps.FindInfoItem(id);

            model.Add(item);
            return(PartialView("EditItemPartial", model));
        }
Ejemplo n.º 3
0
 public ActionResult UpdateInfoItem(FarmInfoItem item)
 {
     try
     {
         InfoItemOps.UpdateInfoItem(item);
         return(Json(item.Id.ToString()));
     }
     catch (Exception e)
     {
         return(new HttpStatusCodeResult(500, e.ToString()));
     }
 }
Ejemplo n.º 4
0
 public ActionResult AddInfoItem(FarmInfoItem item)
 {
     try
     {
         InfoItemOps.AddInfoItem(item);
         return(new HttpStatusCodeResult(200));
     }
     catch (Exception e)
     {
         return(new HttpStatusCodeResult(500, e.ToString()));
     }
 }
Ejemplo n.º 5
0
 public ActionResult DeleteInfoItem(int id)
 {
     try
     {
         FarmInfoItem item = InfoItemOps.FindInfoItem(id);
         InfoItemOps.DeleteInfoItem(item);
         return(new HttpStatusCodeResult(200));
     }
     catch (Exception e)
     {
         return(new HttpStatusCodeResult(500, e.ToString()));
     }
 }
Ejemplo n.º 6
0
        public ActionResult LoadCalendar()
        {
            List <FarmInfoItem> model = InfoItemOps.GetInfoItems("calendar").OrderBy(i => i.Date).ToList();

            return(PartialView("CalendarPartial", model));
        }
Ejemplo n.º 7
0
        public ActionResult LoadNews()
        {
            List <FarmInfoItem> model = InfoItemOps.GetInfoItems("both");

            return(PartialView("NewsPartial", model));
        }