예제 #1
0
        public async Task <ActionResult> AgentRegister(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    db.Execute($"Update AspNetUsers Set UserType='{(int)UserTypeEnum.Agent}' Where Id='{user.Id}'");
                    var item = new AgentDiscount {
                        UserID = user.Id
                    };
                    db.Insert(item);
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                    var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
                    return(Redirect(callbackUrl));
                    //return RedirectToAction("Index", "Home");
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
예제 #2
0
 public ActionResult AgentManage([Bind(Include = "AgentDiscountID,UserID,ServiceTypeID,Amount,Percentage,IsApproved")] AgentDiscount item, ServiceTypeEnum?service)
 {
     item.ServiceTypeID = (int)service;
     base.BaseSave <AgentDiscount>(item, item.AgentDiscountID > 0);
     return(RedirectToAction("Agents"));
 }
예제 #3
0
        public async Task <ActionResult> Manage([Bind(Include = "AgentId,RealName,ContactName,AgencyName,PhoneNo,Email,Address,State,PAN,GST,RCbook,BkAccNo,BkName,BkIFSC,BkAddress,CreditAmt")] AgentView model)
        {
            using (var transaction = db.GetTransaction())
            {
                try
                {
                    if (model.AgentId?.Length > 0)
                    {
                        db.Execute($"Update AspNetUsers Set RealName='{model.RealName}' Where Id='{model.AgentId}'");
                        db.Update(new Agent
                        {
                            Address     = model.Address,
                            State       = model.State,
                            AgentId     = model.AgentId,
                            BkAccNo     = model.BkAccNo,
                            BkAddress   = model.BkAddress,
                            BkIFSC      = model.BkIFSC,
                            BkName      = model.BkName,
                            ContactName = model.ContactName,
                            Email       = model.Email,
                            GST         = model.GST,
                            PAN         = model.PAN,
                            PhoneNo     = model.PhoneNo,
                            RCbook      = model.RCbook,
                            CreditAmt   = model.CreditAmt
                        });
                    }
                    else
                    {
                        var user = new ApplicationUser {
                            UserName = model.Email, Email = model.Email
                        };

                        var result = await UserManager.CreateAsync(user, "Agent1Pwd!");

                        if (result.Succeeded)
                        {
                            db.Execute($"Update AspNetUsers Set UserType='{(int)UserTypeEnum.Agent}' , RealName='{model.RealName}' Where Id='{user.Id}'");
                            db.Insert(new Agent
                            {
                                Address     = model.Address,
                                State       = model.State,
                                AgentId     = user.Id,
                                BkAccNo     = model.BkAccNo,
                                BkAddress   = model.BkAddress,
                                BkIFSC      = model.BkIFSC,
                                BkName      = model.BkName,
                                ContactName = model.ContactName,
                                Email       = model.Email,
                                GST         = model.GST,
                                PAN         = model.PAN,
                                PhoneNo     = model.PhoneNo,
                                RCbook      = model.RCbook,
                                CreditAmt   = model.CreditAmt
                            });
                            var item = new AgentDiscount {
                                UserID = user.Id
                            };
                            db.Insert(item);
                        }
                    }
                    transaction.Complete();
                }
                catch (Exception e)
                {
                    transaction.Dispose();
                    throw e;
                }
            }
            return(RedirectToAction("Index", "Agent"));
        }