Esempio n. 1
0
 public JsonResult OrderTaxi(string from, string to, string phone, string date, string service, decimal?estimatedCost)
 {
     if (IsOrderValid(from, to, phone))
     {
         var request = new Request();
         if (User.Identity.IsAuthenticated)
         {
             var user = _userBl.GetUserByLogin(User.Identity.Name);
             request.CreatorId = user.Id;
         }
         else
         {
             request.CreatorId = null;
         }
         request.OperatorId  = null;
         request.FinishPoint = to;
         request.PhoneNumber = phone;
         request.StartPoint  = from;
         request.Status      = (int)RequestStatusEnum.Active;
         if (date == "")
         {
             request.RequesTime = DateTime.Now;
         }
         else
         {
             request.RequesTime = DateTime.Parse(date);
         }
         request.Additional = service;
         request.Price      = estimatedCost;
         int requestId = _userBl.CreateRequest(request);
         return(Json(new
         {
             RequestId = requestId
         }));
     }
     else
     {
         return(Json(new
         {
             ValidationError = "The spacified order is invalid"
         }));
     }
 }