示例#1
0
 public ActionResult SaveUser(LoggedUser model)
 {
     PureJson result = new PureJson();
     model.Id = MySession.CurrentUser.Id;
     LoggedUser user = Database.UserChange(model);
     if (user != null)
     {
         MySession.CurrentUser = user;
         using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
         {
             jRoot.Add("Status", 0);
         }
         return new SimpleJsonResult(result);
     }
     using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
     {
         jRoot.Add("Status", 1);
     }
     return new SimpleJsonResult(result);
 }
示例#2
0
 public LoggedUser UserChange(LoggedUser input)
 {
     using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
     {
         using (DbCommand command = GetCommand("tblHuogUser_update"))
         {
             SetParameterValue(command, "@Id", input.Id);
             SetParameterValue(command, "@Name", input.Name);
             SetParameterValue(command, "@Email", input.Email);
             SetParameterValue(command, "@Password", input.Password);
             SetParameterValue(command, "@CompanyName", input.CompanyName);
             SetParameterValue(command, "@City", input.City);
             SetParameterValue(command, "@Type", input.Type);
             SetParameterValue(command, "@Employees", input.Employees);
             SetParameterValue(command, "@Income", input.Income);
             SetParameterValue(command, "@Newsletter", input.Newsletter);
             ExecuteNonQuery(command);
         }
         scope.Complete();
     }
     return input;
 }
示例#3
0
        public LoggedUser Register(LoggedUser input)
        {
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                using (DbCommand command = GetCommand("tblHuogUser_insert"))
                {
                    SetParameterValue(command, "@Id", input.Id);
                    GetParameter(command, "@Id").Direction = ParameterDirection.Output;
                    SetParameterValue(command, "@Name", input.Name);
                    SetParameterValue(command, "@Email", input.Email);
                    SetParameterValue(command, "@Password", input.Password);
                    SetParameterValue(command, "@CompanyName", input.CompanyName);
                    SetParameterValue(command, "@City", input.City);
                    SetParameterValue(command, "@Type", input.Type);
                    SetParameterValue(command, "@Employees", input.Employees);
                    SetParameterValue(command, "@Income", input.Income);
                    SetParameterValue(command, "@Newsletter", input.Newsletter);
                    ExecuteNonQuery(command);

                    input.Id =(int)GetParameterValue(command, "Id");
                }
                scope.Complete();
            }
            return input;
        }
示例#4
0
        private int SendRegistrationMail(LoggedUser model)
        {
            string key = "ID=" + model.Id + "&Type=USER";
            EmailUtil email = new EmailUtil(false);

            string content = "Kako biste potvrdili registraciju na portalu huog.hr kliknite na sljedeći link:" + "<br /><br />"
                                + Url.AbsoluteAction("Activate", "Account", new { key = Encryption64Util.CryptStringUInt64(key) })
                                + "<br /><br />"
                                + "Ako ne možete kliknuti na link, akcijom copy-paste kopirajte ga u vaš preglednik." + "<br /><br />";
            if (email.SendHtmlEmail(content, "Potvrda registracije", "*****@*****.**", model.Email, null, null) == 0)
            {
                return 0;
            }
            else
            {
                return -1;
            }
        }
示例#5
0
 public ActionResult Register(LoggedUser model)
 {
     PureJson result = new PureJson();
     if (ModelState.IsValid)
     {
         LoggedUser user = Database.Login(model.Email, model.Password);
         if (user != null)
         {
             using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
             {
                 jRoot.Add("Status", 2);
             }
             return new SimpleJsonResult(result);
         }
         user = Database.Register(model);
         if (user != null)
         {
             int r = SendRegistrationMail(model);
             //FormsAuthentication.SetAuthCookie(model.Email, false);
             //MySession.CurrentUser = user;
             using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
             {
                 jRoot.Add("Status", 0);
             }
             return new SimpleJsonResult(result);
         }
     }
     using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
     {
         jRoot.Add("Status", 1);
     }
     return new SimpleJsonResult(result);
 }