Example #1
0
 public async Task<bool> ActivationMail(EmailModel model)
 {
     Dictionary<string, string> dic = new Dictionary<string, string>();
     dic.Add("<% UserName %>", model.UserName);
     dic.Add("<% Subject %>", model.Subject);
     dic.Add("<% Summary %>", model.Summary);
     dic.Add("<% ModuleLink %>", model.ModuleLink);
     dic.Add("<% LeadName %>", model.LeadName);
     var st = await SendEMail(model.EmailTo, dic, model.Subject, "Estimation.html", "");
     return st;
 }
        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);
        }