public async Task<object> UpdateLatLong(UpdateLatLongModel model)
 {
     DriverService dservice = new DriverService();
     int i=await dservice.UpdateLatLong2(model.UserId, model.UserType, model.Latitude, model.Longitude,model.UpdateDate,model.UpdateTime);
     Dictionary<string, object> dic = new Dictionary<string, object>();
     if (i != 0)
     {
         dic.Add("Code", "200");
         dic.Add("Message", "Global Cords Updated Successfully.");
     }
     else
     {
         dic.Add("Code", "201");
         dic.Add("Message", "Global Cords Not Updated.");
     }
     return dic;
 }
 public DriverController()
 {
     driverService = new DriverService();
 }
 private ActionResult RedirectToLogin(string UserId)
 {
     DriverService dservice = new DriverService();
     UserService us = new UserService();
     string UserType= us.GetUserType(UserId);
     if (UserType == "Driver")
     {
         return RedirectToAction("Index", "Driver", new { area = "En" });
     }
     else if (UserType == "Passenger")
     {
         return RedirectToAction("Index", "Passenger", new { area = "En" });
     }
     return RedirectToAction("Index", "Home");
 }
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                string filename = ConfigurationManager.AppSettings["PhotoDir"].TrimStart('~') + "user.png";
                var user = new ApplicationUser { UserName = model.UserName, Email = model.Email };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
                    EmailModel em = new EmailModel();
                    string token = usService.GetSecurityStamp(user.Id);
                    em.UserName = model.Name;
                    em.Subject = "[Lira Taxi]- Your Registration Successfully.";
                    em.Summary = "Please active your account to click on below button.";
                    em.ModuleLink = ConfigurationManager.AppSettings["WebDomain"] + "Account/ConfirmEmail?UserId=" + user.Id + "&code=" + token;
                    em.LeadName = "Thanks for Register on Lirataxi.com";
                    em.EmailTo = ConfigurationManager.AppSettings["EstimationMail"] + ";" + model.Email; // ; saperated email ids.
                    var bl = await sendMail.ActivationMail(em);

                    int i = 0;
                    if (model.UserType == "1")
                    {
                        DriverService db = new DriverService();
                        DriverModel md = new DriverModel();
                        md.UserId = user.Id;
                        md.DriverName = model.Name;
                        md.Email = model.Email;
                        md.Mobile = model.Mobile;
                        md.Password = model.Password;
                        md.Longitude = "0";
                        md.Latitude = "0";
                        md.DeviceToken = "";
                        md.DeviceType = "";
                        md.UpdateTime = DateTime.Now;
                        md.nWayPoint = 0;
                        md.nWayInfo = "";
                        md.Paypal = "";
                        md.Status = "OffDuty";
                        md.Language = "En";
                        md.CrDate = DateTime.Now;
                        md.PhotoUrl = filename;
                        i = db.AddDriver(md);
                        if (i == 0)
                        {
                            return View(model);
                        }
                        else
                        {
                            return RedirectToAction("Index", "Driver", new { area = "En" });
                        }
                    }
                    else if (model.UserType == "2")
                    {
                        PassengerService db = new PassengerService();
                        PassengerModel md = new PassengerModel();
                        md.UserId = user.Id;
                        md.FirstName = model.Name;
                        md.Email = model.Email;
                        md.Mobile = model.Mobile;
                        md.Password = model.Password;
                        md.Longitude = "0";
                        md.Latitude = "0";
                        md.DeviceToken = "";
                        md.DeviceType = "";
                        md.UpdateTime = DateTime.Now;
                        md.nWayPoint = 0;
                        md.nWayInfo = "";
                        md.Paypal = "";
                        md.Language = "En";
                        md.CrDate = DateTime.Now;
                        md.PhotoUrl = filename;
                        i = db.AddPassenger(md);
                        if (i == 0)
                        {
                            return View(model);
                        }
                        else
                        {
                            return RedirectToAction("Index", "Passenger", new { area = "En" });
                        }
                    }
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }