Ejemplo n.º 1
0
 public JsonResult Edit(Trip Trip)
 {
     return CreateOrUpdateTrip(Trip);
 }
Ejemplo n.º 2
0
        private JsonResult CreateOrUpdateTrip(Trip Trip)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var parameters = new List<KeyValuePair<string, string>>
                    {
                        new KeyValuePair<string,string>("Id", Trip.Id.ToString()),
                        new KeyValuePair<string,string>("Destination", Trip.Destination),
                        new KeyValuePair<string,string>("StartDate", Trip.StartDate.ToString()),
                        new KeyValuePair<string,string>("EndDate", Trip.EndDate.ToString()),
                        new KeyValuePair<string,string>("Comment", Trip.Comment),
                        new KeyValuePair<string,string>("UserId", Trip.UserId.ToString()),
                    };

                    var url = UriHelper.GetFormedUrl(URIs.CreateOrUpdateTripUri, parameters);

                    var token = TokenHelper.GetAuthenticationToken();

                    var intId = APIHelper.PostRequest(url, token).Content.ReadAsAsync<int>().Result;

                    return new JsonResult { Data = new { Message = Message.SuccesfulSave } };
                }
                else
                {
                    return GetModelStateErrors();
                }
            }
            catch (HttpException ex)
            {
                return new JsonResult { Data = new { Error = true, Message = ex.Message } };
            }
        }