コード例 #1
0
 public ActionResult editAreaItemData(string submit, string Name,string Description, string isAreaID, int AreaItemID = 0)
 {
     AreaItemResponse areaItem = ApiWrapper.Get<AreaItemResponse>("api/areaitem/get/" + AreaItemID);
     CreateAreaItemRequest request = new CreateAreaItemRequest();
     if (submit != null)
     {
         submit = submit.ToLower();
         if (isAreaID.ToLower()!="false")
         {
             request.AreaID = AreaItemID;
             request.AreaItemID = 0;
         }
         else
         {
             request.AreaID = areaItem.AreaID;
             request.AreaItemID = areaItem.AreaItemID;
         }
         request.RoomItem = Name;
         request.RoomDescription = Description;
         if (submit == "save")
         {
             var result = ApiWrapper.Post<String>("api/areaitem/add", request);
         }
         else if (submit == "delete" && AreaItemID != 0)
         {
             var result = ApiWrapper.Post<bool>("api/areaitem/remove", request);
         }
     }
     else
     {
         return Redirect("/property/list");
     }
     return Redirect("/property/manageAreaItems/" + request.AreaID);
 }
コード例 #2
0
        public JsonResult Add(CreateAreaItemRequest request)
        {
            if (request.AreaItemID <= 0)
            {
                AreaItem areaItem = new AreaItem();
                areaItem.AreaItemID = request.AreaItemID;
                areaItem.RoomDescription = request.RoomDescription;
                areaItem.RoomItem = request.RoomItem;
                areaItem.AreaID = request.AreaID; 

                db.AreaItems.Add(areaItem);
                db.SaveChanges();
            }
            else
            {
                AreaItem areaItem = db.AreaItems.Where(x => x.AreaItemID == request.AreaItemID).FirstOrDefault();
                if (areaItem != null)
                {
                    areaItem.AreaItemID = request.AreaItemID;
                    areaItem.RoomDescription = request.RoomDescription;
                    areaItem.RoomItem = request.RoomItem;
                    areaItem.AreaID = request.AreaID;

                    db.SaveChanges();
                }

            }

            return Json("true");
        }
コード例 #3
0
        public JsonResult AddedAreaItem(AreaItemResponse model)
        {
            CreateAreaItemRequest request = new CreateAreaItemRequest();
            request.AreaItemID = model.AreaItemID;
            request.RoomItem = model.RoomItem;
            request.AreaID = model.AreaID;
            request.RoomDescription = model.RoomDescription;

            var result = ApiWrapper.Post<AreaItemResponse>("api/areaitem/add", request);

            return Json(result);
        }
コード例 #4
0
 public JsonResult Remove(CreateAreaItemRequest request)
 {
     AreaItem areaItem = null;
     bool removed = false;
     if (request.AreaID > 0)
     {
         areaItem = db.AreaItems.Where(x => x.AreaItemID == request.AreaItemID).FirstOrDefault();
         db.AreaItems.Remove(areaItem);
         db.SaveChanges();
         removed = true;
     }
     return Json(removed, JsonRequestBehavior.AllowGet);
 }