Ejemplo n.º 1
0
        public override string PrepareTemplate(object datalist)
        {
            LMYFrameWorkMVC.Common.TemplateLists.Regestration regestration = datalist as LMYFrameWorkMVC.Common.TemplateLists.Regestration;

            return("html template: " + regestration.Email);
        }
Ejemplo n.º 2
0
        public void Create(UserModel userModel, CommonLayer.Entities.ITemplate regestrationCompleted)
        {
            try
            {
                //if (!base.UserHasPermision(userModel))
                //    return;

                //example of tasks
                //for (int i = 0; i < 10000000; i++)
                //    base.AddWaitingAction((async () =>
                //    {
                //        System.Threading.Thread.Sleep(1000);
                //    }));

                if (Validate(userModel))
                {
                    return;
                }

                using (var transaction = dbContext.Database.BeginTransaction())
                {
                    try
                    {
                        AspNetUser aspNetUser = new AspNetUser();
                        UserMapper.Map(dbContext, userModel, aspNetUser);
                        aspNetUser.PasswordHash = Hasher.HashString(userModel.Password);
                        aspNetUser.Id           = Guid.NewGuid().ToString();
                        //aspNetUser.AspNetRoles = userModel.RolesIDs.Select(x => dbContext.AspNetRoles.Find(x)).ToList();
                        aspNetUser.EmailConfirmed = true;
                        aspNetUser.SecurityStamp  = Guid.NewGuid().ToString();
                        dbContext.AspNetUsers.Add(aspNetUser);

                        base.SaveChanges();
                        transaction.Commit();

                        userModel.AddSuccess(Resources.UserAddedSuccessfully, LookUps.SuccessType.Full);

                        CommonLayer.TemplateLists.Regestration regestration = new CommonLayer.TemplateLists.Regestration();

                        regestration.ID       = aspNetUser.Id;
                        regestration.UserName = aspNetUser.UserName;

                        //call method in base call (IEmail,to,cc,title)
                        //if (regestrationCompleted != null)
                        //{
                        //    //pass the parameters and then send the email from here
                        //    //regestrationCompleted.PrepareTemplate(regestration);
                        //}
                        //base.SendEmail()
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                base.HandleError(userModel, CommonLayer.LookUps.ErrorType.Exception, ex);
                base.UndoUpdates();
            }
        }