コード例 #1
0
        public IHttpActionResult Loginreturn([FromUri] FanapModel fanapModel)
        {
            try
            {
                var            res    = new UserRegisterModel();
                var            fModel = _fanapManager.GetFanapUserInfo(fanapModel);
                IdentityResult result;
                var            userObj = new ApplicationUser()
                {
                    UserName = fModel.UserName, Name = fModel.Name, Family = fModel.Family, MobileConfirmed = false, Code = "Fanap"
                };
                //var userObj = new ApplicationUser() { Name = model.Name, Family = model.Family, Gender = model.Gender, UserName = model.Mobile,Code=model.Code, MobileConfirmed = false };
                var user    = AppUserManager.FindByName(fModel.UserName);
                var newPass = System.Web.Security.Membership.GeneratePassword(16, 0);
                if (user == null)
                {
                    result = AppUserManager.Create(userObj, newPass);
                    if (result.Succeeded)
                    {
                        user = AppUserManager.FindByName(fModel.UserName);
                        AppUserManager.AddToRole(user.Id, UserRoles.MobileDriver.ToString());
                        _fanapManager.SaveFanapUser(user.Id, fModel.UserId);
                        res.Mobile   = fModel.UserName;
                        res.Password = newPass;
                        return(Json(_responseProvider.GenerateResponse(res, "userpass")));

                        /*var url = "http://exitthisactivity";
                         * var response = Request.CreateResponse(HttpStatusCode.Moved);
                         * response.Headers.Location = new Uri(url);
                         * return response;*/
                    }
                }
                else
                {
                    _fanapManager.SaveFanapUser(user.Id, fModel.UserId);
                    result = AppUserManager.RemovePassword(user.Id);
                    if (result.Succeeded)
                    {
                        result = AppUserManager.AddPassword(user.Id, newPass);
                        if (result.Succeeded)
                        {
                            bool isUserRegistered = !string.IsNullOrEmpty(user.Name);
                            user.MobileConfirmed = true;
                            AppUserManager.Update(user);
                            res.Mobile   = fModel.UserName;
                            res.Password = newPass;
                            return(Json(_responseProvider.GenerateResponse(res, "userpass")));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                _logmanager.Log(Tag, "Loginreturn", e.Message);
            }
            return(Json(_responseProvider.GenerateUnknownErrorResponse()));
        }
コード例 #2
0
 public IHttpActionResult GetPathPrice(SrcDstModel model)
 {
     try
     {
         var           routePrice    = _routemanager.GetPathPrice(model);
         ResponseModel responseModel = _responseProvider.GenerateResponse(routePrice, "pathprice");
         return(Json(responseModel));
     }
     catch (Exception e)
     {
         _logmanager.Log(Tag, "GetPathPrice", e.Message);
     }
     return(null);
 }
コード例 #3
0
        public IHttpActionResult SubmitPassDiscount(DiscountModel model)
        {
            try
            {
                if (model == null)
                {
                    _responseProvider.SetBusinessMessage(new MessageResponse()
                    {
                        Type    = ResponseTypes.Error,
                        Message =
                            string.Format(getResource.getMessage("Required"), getResource.getString("VerificationCode"))
                    });
                    return(Json(_responseProvider.GenerateBadRequestResponse()));
                }
                var res = _userManager.DoDiscount(InviteTypes.PassInvite, model.DiscountCode,
                                                  int.Parse(User.Identity.GetUserId()));
                if (res)
                {
                    return
                        (Json(_responseProvider.GenerateResponse(getResource.getMessage("CodeSubmitted"), "CodeSubmitted")));
                }
                else
                {
                    return(Json(_responseProvider.GenerateBadRequestResponse()));
                }

                /*if (_userManager.DiscountCodeExist(model))
                 * {
                 *  if (_userManager.DiscountCodeUsed(model, int.Parse(User.Identity.GetUserId())))
                 *  {
                 *      _responseProvider.SetBusinessMessage(new MessageResponse() { Message = getResource.getMessage("CodeUsed"), Type = ResponseTypes.Error });
                 *      return Json(_responseProvider.GenerateBadRequestResponse());
                 *  }
                 *  else
                 *  {
                 *      _userManager.InsertDiscountCode(model, int.Parse(User.Identity.GetUserId()));
                 *      return Json(_responseProvider.GenerateResponse(getResource.getMessage("CodeSubmitted"), "CodeSubmitted"));
                 *  }
                 * }
                 * else
                 * {
                 *  _responseProvider.SetBusinessMessage(new MessageResponse() { Message = getResource.getMessage("CodeNotExist"), Type = ResponseTypes.Error });
                 *  return Json(_responseProvider.GenerateBadRequestResponse());
                 * }*/
            }
            catch (Exception e)
            {
                _logmanager.Log(Tag, "SubmitPassDiscount", e.Message);
            }
            return(Json(_responseProvider.GenerateUnknownErrorResponse()));
        }
コード例 #4
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()));
        }
コード例 #5
0
        public IHttpActionResult ConfirmRoute(ConfirmationModel model)
        {
            ResponseModel responseModel;

            try
            {
                if (!ModelState.IsValid)
                {
                    return(Json(_responseProvider.GenerateBadRequestResponse(ModelState)));
                }
                var res = _routemanager.ConfirmRoute(model, int.Parse(User.Identity.GetUserId()));
                return(Json(_responseProvider.GenerateResponse(new List <string> {
                    res
                }, "AcceptSuggestedRoute")));
                //responseModel = new ResponseModel() { Status = HttpStatusCode.OK.ToString(), StatusCode = HttpStatusCode.OK, Count = 0, Type = ResponseTypes.ConfirmMessage.ToString() };
            }
            catch (Exception e)
            {
                _logmanager.Log(Tag, "ConfirmRoute", e.Message);
            }
            return(Json(_responseProvider.GenerateUnknownErrorResponse()));
        }
コード例 #6
0
        public IHttpActionResult InvokeTrips()
        {
            try
            {
                var res = _routemanager.InvokeTrips();
                //return Json(_responseProvider.GenerateResponse(new List<string> {res}, "InvokeTrips"));
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    _logmanager.Log(Tag, "InvokeTrips", e.Message + "-" + e.InnerException.Message);
                }
                else
                {
                    _logmanager.Log(Tag, "InvokeTrips", e.Message);
                }
            }
            try
            {
                var res = _routemanager.InvokeFilters();
                //return Json(_responseProvider.GenerateResponse(new List<string> {res}, "InvokeTrips"));
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    _logmanager.Log(Tag, "InvokeFilters", e.Message + "-" + e.InnerException.Message);
                }
                else
                {
                    _logmanager.Log(Tag, "InvokeFilters", e.Message);
                }
            }
            try
            {
                var res = _routemanager.SendDriverNotifs();
                //return Json(_responseProvider.GenerateResponse(new List<string> { res }, "InvokeTrips"));
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    _logmanager.Log(Tag, "SendDriverNotifs", e.Message + "-" + e.InnerException.Message);
                }
                else
                {
                    _logmanager.Log(Tag, "SendDriverNotifs", e.Message);
                }
            }
            try
            {
                var res = _routemanager.SetUserNotifications();
                //return Json(_responseProvider.GenerateResponse(new List<string> { res }, "InvokeTrips"));
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    _logmanager.Log(Tag, "SetUserNotifications", e.Message + "-" + e.InnerException.Message);
                }
                else
                {
                    _logmanager.Log(Tag, "SetUserNotifications", e.Message);
                }
            }
            try
            {
                var res = _routemanager.SendNewBookedMessages();
                return(Json(_responseProvider.GenerateResponse(new List <string> {
                    res
                }, "InvokeTrips")));
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    _logmanager.Log(Tag, "SendNewBookedMessages", e.Message + "-" + e.InnerException.Message);
                }
                else
                {
                    _logmanager.Log(Tag, "SendNewBookedMessages", e.Message);
                }
            }

            return(Json(_responseProvider.GenerateUnknownErrorResponse()));
        }