Beispiel #1
0
 public IHttpActionResult InsertUserRoute(RouteRequestModel model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(Json(_responseProvider.GenerateBadRequestResponse(ModelState)));
         }
         var    routeIds              = _routemanager.InsertUserRoute(model, int.Parse(User.Identity.GetUserId()));
         var    confirmMessage        = _routemanager.GetRouteConfirmationMessage(int.Parse(User.Identity.GetUserId()), routeIds);
         string commaSepratedRouteIds = "";
         foreach (var routeId in routeIds)
         {
             commaSepratedRouteIds += routeId + ",";
         }
         ResponseModel responseModel = new ResponseModel()
         {
             Status = HttpStatusCode.OK.ToString(), StatusCode = HttpStatusCode.OK, Count = 1, Type = ResponseTypes.ConfirmMessage.ToString(), Messages = new List <string>()
             {
                 commaSepratedRouteIds, confirmMessage
             }
         };
         return(Json(responseModel));
     }
     catch (Exception e)
     {
         _logmanager.Log(Tag, "InsertUserRoute", e.Message);
     }
     return(Json(_responseProvider.GenerateUnknownErrorResponse()));
 }
 public IHttpActionResult ChargeUserAccount(ChargeModel model)
 {
     try
     {
         var user = AppUserManager.FindByName(model.MobileNo);
         if (user == null)
         {
             _responseProvider.SetBusinessMessage(new MessageResponse()
             {
                 Type    = ResponseTypes.Error,
                 Message = getResource.getMessage("UserNotFound")
             });
             return(Json(_responseProvider.GenerateBadRequestResponse()));
         }
         else
         {
             var res = _paymentManager.ChargeAccount(user.Id, model.ChargeValue, GetUserNameFamilyString(user));
             return(Json(res));
         }
     }
     catch (Exception e)
     {
         _logProvider.Log(Tag, "ChargeUserAccount", e.Message);
     }
     return(Json(_responseProvider.GenerateUnknownErrorResponse()));
 }
Beispiel #3
0
        public IHttpActionResult ConfirmAppointment(AppointmentModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(_responseProvider.GenerateBadRequestResponse(ModelState)));
            }
            try
            {
                var res = _groupManager.ConfirmAppointment(int.Parse(User.Identity.GetUserId()), model);

                return(Json(_responseProvider.GenerateResponse(new List <string> {
                    res
                }, "ConfirmAppointment")));
            }
            catch (Exception e)
            {
                _logProvider.Log(Tag, "ConfirmAppointment", e.Message);
            }
            return(Json(_responseProvider.GenerateUnknownErrorResponse()));
        }
 public IHttpActionResult SaveDriverGcmToken(Gtoken model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(Json(_responseProvider.GenerateBadRequestResponse(ModelState)));
         }
         _userManager.InsertGoogleToken(int.Parse(User.Identity.GetUserId()), model, UserRoles.MobileDriver);
         return(Json(_responseProvider.GenerateOKResponse()));
     }
     catch (Exception e)
     {
         _logmanager.Log(Tag, "SaveDriverGcmToken", e.Message);
     }
     return(Json(_responseProvider.GenerateUnknownErrorResponse()));
 }
Beispiel #5
0
        public IHttpActionResult RequestPayBooking(PayModel model)
        {
            try
            {
                int ff;
                if (User != null && int.TryParse(User.Identity.GetUserId(), out ff))
                {
                    if (_routemanager.IsPayValid(ff, model))
                    {
                        if (_routemanager.HasCapacity(model))
                        {
                            if (!_routemanager.HasReserved(model, ff))
                            {
                                if (model.ChargeAmount > 0)
                                {
                                    //gotobank
                                    var res = _routemanager.RequestPayBooking(ff, model.TripId, model.ChargeAmount);
                                    return(Json(res));

                                    /*var res = _routemanager.RequestBooking(ff, model.TripId, model.ChargeAmount);
                                     * return Json(res);*/
                                }
                                else
                                {
                                    var res1 = _routemanager.BookSeat(ff, model);
                                    return(Json(res1));
                                }
                            }
                            else
                            {
                                _responseProvider.SetBusinessMessage(new MessageResponse()
                                {
                                    Type    = ResponseTypes.Error,
                                    Message = getResource.getMessage("SeatPreviouslyReserved")
                                });
                                return(Json(_responseProvider.GenerateBadRequestResponse()));
                            }
                        }
                        else
                        {
                            _responseProvider.SetBusinessMessage(new MessageResponse()
                            {
                                Type    = ResponseTypes.Error,
                                Message = getResource.getMessage("NoEmptySeat")
                            });
                            return(Json(_responseProvider.GenerateBadRequestResponse()));
                        }
                    }
                    else
                    {
                        _responseProvider.SetBusinessMessage(new MessageResponse()
                        {
                            Type    = ResponseTypes.Error,
                            Message = getResource.getMessage("PricesUnDefined")
                        });
                        return(Json(_responseProvider.GenerateBadRequestResponse()));
                    }
                }
                else
                {
                    return
                        (ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.Unauthorized,
                                                                     "You are unauthorized to see Info!")));
                }
            }
            catch (Exception e)
            {
                _logmanager.Log(Tag, "RequestPayBooking", e.Message);
            }
            return(Json(_responseProvider.GenerateUnknownErrorResponse()));
        }