示例#1
0
        public List <RoomsDetailsView> GetRoomsSetting([FromBody] JObject dates)
        // public List<RoomsDetailsView> GetRoomsSetting()
        {//בחדר מספר 0 נמצאים כל הכלבים בהזמנות שלא שובצו
            // DateTime fromDate=new DateTime(DateTime.Now.Year,DateTime.Now.Month,DateTime.Now.Day).AddDays(2); DateTime toDate= new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(4);
            RoomsServie roomService = new RoomsServie();
            //DateTime fromDate = DateTime.Now;
            //DateTime toDate = DateTime.Now.AddDays(1);
            string json = JsonConvert.SerializeObject(dates);
            //DateTime fromDate = JObject.Parse(json)["@fromDate"];
            //var toDate = JObject.Parse(json)["@toDate"];
            var      data     = (JObject)JsonConvert.DeserializeObject(json);
            DateTime fromDate = data["fromDate"].Value <DateTime>();
            //var jArray = JArray.Parse(json);
            //DateTime fromDate = jArray[0]["fromDate"].Value<DateTime>();
            //  DateTime toDate = data["toDate"].Value<DateTime>();
            int fromShift = data["fromShift"].Value <int>();
            //  int toShift = data["toShift"].Value<int>();
            List <RoomsDetailsView> list             = roomService.GetRoomsSetting(fromDate, fromShift);
            RoomsDetailsView        roomsDetailsView = new RoomsDetailsView();

            roomsDetailsView.dogsInRoom   = roomService.GetDogsNoSetting(fromDate, fromShift);
            roomsDetailsView.RoomCapacity = 0;
            roomsDetailsView.RoomID       = 0;
            list.Insert(0, roomsDetailsView);
            return(list);
            //  List<RoomsDetailsView> rooms = roomService.GetRooms();
            //  return rooms;
        }
示例#2
0
        public HttpResponseMessage AddRoom([FromBody] RoomsDetailsView roomsDetails)
        {
            try
            {
                //var jsonString = userNew.Content.ReadAsStringAsync().Result;
                // UserDetailsView user = JsonConvert.DeserializeObject<UserDetailsView>(userNew);
                RoomValidator    validator = new RoomValidator();
                ValidationResult results   = validator.Validate(roomsDetails);
                if (results.IsValid)
                {
                    RoomsServie roomsServie = new RoomsServie();
                    roomsServie.AddRoom(roomsDetails);
                    return(Request.CreateResponse(HttpStatusCode.OK));

                    //  return Ok();
                }
                else
                {
                    //List<string> errorlist = new List<string>();
                    //foreach (var value in results.Errors)
                    //{
                    //    errorlist.Add(value.ErrorMessage);
                    //}
                    return(Request.CreateResponse(HttpStatusCode.BadRequest));
                }
            }
            catch (HttpRequestException ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
                // throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.BadRequest,
                //                           badInputValidationException.Result));
                //Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
            }
        }
示例#3
0
 public HttpResponseMessage UpdateRoomsDetailsAndSetting(List <RoomsDetailsView> listRoomsDetails)
 {
     try
     {
         RoomsServie roomsServie = new RoomsServie();
         roomsServie.UpdateRoomsDetailsAndSetting(listRoomsDetails);
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
     catch
     {
         return(Request.CreateResponse(HttpStatusCode.NotModified));
     }
 }