private static void CreateUserFromTemplate(UserManager<ApplicationUser> userManager, UserTemplate userTemplate)
 {
     if (!userManager.Users.Any(user => user.UserName == userTemplate.UserName))
     {
         var user = new ApplicationUser() {UserName = userTemplate.UserName, Email = userTemplate.Email};
         CreateUserSync(userManager, userTemplate, user);
     }
 }
Beispiel #2
0
 public Preview()
 {
     InitializeComponent();
     Browser.Navigate(new Uri(UserTemplate.Load()));
     Loaded                 += OnLoaded;
     Unloaded               += (sender, args) => _templateWatcher?.Dispose();
     Browser.Navigating     += BrowserOnNavigating;
     Browser.PreviewKeyDown += BrowserPreviewKeyDown;
     Browser.MessageHook    += BrowserOnMessageHook;
     Browser.Unloaded       += (s, e) => ApplicationCommands.Close.Execute(null, Application.Current.MainWindow);
     UpdatePreview           = Utility.Debounce <Editor>(editor => Dispatcher.InvokeAsync(() => Update(editor.Text)));
 }
Beispiel #3
0
        private async void b_login_Click(object sender, RoutedEventArgs e)
        {
            // TODO : READ WHAT TYPE OF THE USER IS THE PERSON LOGIN IN

            /**
             * Kinda cheating here
             * Getting the current executing main window and revert it to original state
             * Then we hide the main window and open the new login window
             */
            string dir = Directory.GetCurrentDirectory() + "\\Data\\users.json";
            List <UserTemplate> allUsers;

            using (var streamReader = new StreamReader(dir))
                using (JsonReader reader = new JsonTextReader(streamReader))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    allUsers = serializer.Deserialize <List <UserTemplate> >(reader);
                }
            UserTemplate authUser = null;

            allUsers.ForEach(delegate(UserTemplate user)
            {
                if (tb_username.Text == user.username)
                {
                    if (pb_password.Password == user.password)
                    {
                        authUser = user;
                    }
                }
            });
            MainWindow   mainWindow;
            PlayerWindow n_window;

            if (authUser != null)
            {
                //TODO Check Role
                mainWindow = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();
                mainWindow.hideBackButton();
                NavigationService.GoBack();
                n_window = new PlayerWindow(authUser);
                n_window.Show();
                mainWindow.Hide();
            }
            else
            {
                var metroWindow = (Application.Current.MainWindow as MetroWindow);
                await metroWindow.ShowMessageAsync("Login Failed", "Wrong Username and/or Password", MessageDialogStyle.Affirmative);

                br_un.Background   = new SolidColorBrush(Colors.Red);
                br_pass.Background = new SolidColorBrush(Colors.Red);
            }
        }
 private void PrepareForm()
 {
     FillData();
     GetData();
     if (UserTemplate.HasPrivilege("btnAdd"))
     {
         btnAdd.Enabled = true;
     }
     else
     {
         btnAdd.Enabled = false;
     }
 }
Beispiel #5
0
        public ActionResult TemplateRequest(int templateid, string name)
        {
            //find the template via entity framework
            UserTemplate userTemplate = db.UserTemplates.Find(templateid);

            //transform our cells value to
            var html = TemplateToHTML(CellsToGrid(userTemplate));

            //return our updated game string
            Object returnObj = new { html = html };

            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }
Beispiel #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            UserTemplate userTemplate = db.UserTemplates.Find(id);

            //check if we own the template
            if (userTemplate.UserID != (int)Session["UserID"])
            {
                return(RedirectToAction("Index", "Home", 405));
            }
            db.UserTemplates.Remove(userTemplate);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #7
0
        private void PrepareForm()
        {
            FillData();

            if (UserTemplate.HasPrivilege("btnSave"))
            {
                btnSave.IsEnabled = true;
            }
            else
            {
                btnSave.IsEnabled = false;
            }
        }
Beispiel #8
0
        public ActionResult Create([Bind(Include = "UserTemplateID,UserID,Name,Height,Width,Cells")] UserTemplate userTemplate)
        {
            if (ModelState.IsValid)
            {
                //just to be sure we want all cells strings to be lower case
                userTemplate.Cells = CellsToLower(userTemplate.Cells);
                db.UserTemplates.Add(userTemplate);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserID = new SelectList(db.Users, "UserID", "Email", userTemplate.UserID);
            return(View(userTemplate));
        }
Beispiel #9
0
        public void UserSerializationTest()
        {
            //Getting user applicaitondata folder.
            string LocalAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string programFolder    = System.IO.Path.Combine(LocalAppDataPath, "Munchy");

            //Data File Locations
            string userFile = System.IO.Path.Combine(programFolder, "USER.json");

            string userFridgeFile = System.IO.Path.Combine(programFolder, "USER_FRIDGE.json");

            string foodDefFile    = System.IO.Path.Combine(programFolder, "FoodData.json");
            string recipeDatabase = System.IO.Path.Combine(programFolder, "Recipes.json");

            string recipeSaveFile     = System.IO.Path.Combine(programFolder, "RecipeSavesFile.json");
            string statSavePath       = System.IO.Path.Combine(programFolder, "StatSavePath.json");
            string m_ShoppingListFile = System.IO.Path.Combine(programFolder, "ShoppingList.json");


            ProgramManager currentManager = new ProgramManager(userFile, userFridgeFile, recipeDatabase, foodDefFile, recipeSaveFile, statSavePath, m_ShoppingListFile);
            List <string>  preferences    = new List <string>
            {
                "isvegan",
                "isvegetarian",
                "isdiabetic",
                "eggs",
                "dairy",
                "fish",
                "nuts",
                "gluten",
                "soy"
            };

            currentManager.User.UserName     = "******";
            currentManager.User.Age          = 17;
            currentManager.User.Weight       = 89;
            currentManager.User.Sex          = "male";
            currentManager.User.LanguagePref = "EN";
            currentManager.User.Preferences  = preferences;
            currentManager.SaveUser();

            UserTemplate newUser = currentManager.GetUser();

            Assert.IsTrue(newUser.UserName == "Nikola");
            Assert.IsTrue(newUser.Age == 17);
            Assert.IsTrue(newUser.Weight == 89);
            Assert.IsTrue(newUser.Sex == "male");
            Assert.IsTrue(newUser.LanguagePref == "EN");
            Assert.IsTrue(newUser.Preferences.Count == preferences.Count);
        }
Beispiel #10
0
        private void PrepareForm()
        {
            GetValidPumps();
            if (UserTemplate.HasPrivilege("btnSave"))
            {
                btnSave.Enabled = true;
            }
            else
            {
                btnSave.Enabled = false;
            }

            btnPrint.Enabled = false;
        }
Beispiel #11
0
        // GET: UserTemplates
        public ActionResult CreateGame(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserTemplate userTemplate = db.UserTemplates.Find(id);

            if (userTemplate == null)
            {
                return(HttpNotFound());
            }
            return(RedirectToAction("CreateFromTemplate", "UserGames", userTemplate));
        }
Beispiel #12
0
        // GET: UserTemplates/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserTemplate userTemplate = db.UserTemplates.Find(id);

            if (userTemplate == null)
            {
                return(HttpNotFound());
            }
            return(View(userTemplate));
        }
Beispiel #13
0
        public async Task GetUser_MatchEmailAddress_ReturnUsers()
        {
            UserTemplate user1 = await TestRunner.InsertTemplateAsync(new UserTemplate
            {
                { "FirstName", "user1" },
                { "EmailAddress", "*****@*****.**" }
            });

            UserTemplate user2 = await TestRunner.InsertTemplateAsync(new UserTemplate
            {
                { "FirstName", "user2" },
                { "EmailAddress", "*****@*****.**" }
            });

            await TestRunner.InsertTemplateAsync(new UserAddressTemplate
            {
                { "UserId", user1.Identity },
                { "Postcode", "HD6 3UB" }
            });

            await TestRunner.InsertTemplateAsync(new UserAddressTemplate
            {
                { "UserId", user2.Identity },
                { "Postcode", "HD6 4UB" }
            });

            IList <QueryResult> result = await TestRunner.ExecuteStoredProcedureMultipleDataSetAsync("dbo.GetUser", new SqlQueryParameter("EmailAddress", "*****@*****.**"));

            result[0]
            .AssertRowCount(2)
            .AssertColumnsExist("FirstName", "LastName", "Postcode")
            .AssertRowValues(0, new DataSetRow
            {
                { "FirstName", "user1" },
                { "LastName", "Burns" },
                { "Postcode", "HD6 3UB" }
            })
            .AssertRowValues(1, new DataSetRow
            {
                { "FirstName", "user2" },
                { "LastName", "Burns" },
                { "Postcode", "HD6 4UB" }
            });

            result[1]
            .AssertRowCount(1)
            .AssertColumnsExist("TotalUsers")
            .AssertValue(0, "TotalUsers", 2);
        }
Beispiel #14
0
        private void PrepareForm()
        {
            FillData();
            lstPumpStat.Text = "متاحة";
            if (UserTemplate.HasPrivilege("btnSave"))
            {
                btnSave.Enabled = true;
            }
            else
            {
                btnSave.Enabled = false;
            }

            btnUpdate.Enabled = false;
        }
        private void PrepareForm()
        {
            FillData();
            nmbTotal.DecimalPlaces = glb_function.glb_iMainCurrDecimal;
            if (UserTemplate.HasPrivilege("btnSave"))
            {
                btnSave.Enabled = true;
            }
            else
            {
                btnSave.Enabled = false;
            }

            btnPrint.Enabled = false;
        }
Beispiel #16
0
        private UserTemplate ExtractUserTemplate()
        {
            CheckInputs();
            UserTemplate temp = new UserTemplate();

            temp.Username = txtUsername.Text;
            temp.PIN = txtPin.Text;
            temp.LockID = txtLockId.Text;
            temp.IsAdministrator = cmbUsertype.SelectedIndex == 0 ? false : true;
            if (temp.IsAdministrator) temp.Password = txtPassword.Password;
            else temp.Password = "";
            temp.IsEnabled = chbxIsEnabled.IsChecked == true ? true : false;

            return temp;
        }
Beispiel #17
0
        // GET: UserTemplates/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserTemplate userTemplate = db.UserTemplates.Find(id);

            if (userTemplate == null)
            {
                return(HttpNotFound());
            }
            ViewBag.UserID = new SelectList(db.Users, "UserID", "UserName", userTemplate.UserID);
            return(View(userTemplate));
        }
Beispiel #18
0
        private void PrepareForm()
        {
            FillData();
            ckbSellingPriceEditable.IsChecked = false;
            if (UserTemplate.HasPrivilege("btnSave"))
            {
                btnSave.IsEnabled = true;
            }
            else
            {
                btnSave.IsEnabled = false;
            }

            btnUpdate.IsEnabled = false;
        }
Beispiel #19
0
        private void GetData(string strInvoicePkid)
        {
            new glb_function().clearItems(this);

            ConnectionToMySQL cnn       = new ConnectionToMySQL();
            DataTable         dtInvoice = cnn.GetDataTable("SELECT h.pkid pkheader,h.invoice_no,h.invoice_note,h.invoice_value,date_format(h.invoice_date,'%d/%m/%Y') invoice_date , " +
                                                           " d.warehouse_id, d.pump_emp, d.pump_id, p.PumpNo, p.PumpName, d.emp_id, e.empname, d.old_counter, d.new_counter, " +
                                                           " d.item_id, i.itemname, d.qty, d.unitsellingPrice, d.TotalSellingPrice " +
                                                           " FROM invoice_header h " +
                                                           "  join invoice_details d on(h.pkid = d.header_id) " +
                                                           "  join pumps p on(p.pkid = d.pump_id) " +
                                                           "  join emp e on(e.pkid = d.emp_id) " +
                                                           "  join items i on(i.pkid = d.item_id) " +
                                                           "  where h.pkid=" + strInvoicePkid);

            txtPkid.Text      = strInvoicePkid;
            txtInvoiceNo.Text = dtInvoice.Rows[0]["invoice_no"].ToString();

            nmbTotalSellingPrice.Value = Convert.ToDecimal(dtInvoice.Rows[0]["TotalSellingPrice"].ToString());
            txtInvoiceNote.Text        = dtInvoice.Rows[0]["invoice_note"].ToString();
            dtpJourDate.Value          = DateTime.ParseExact(dtInvoice.Rows[0]["invoice_date"].ToString(), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);

            for (int i = 0; i < dtInvoice.Rows.Count; i++)
            {
                dgvInvoices.Rows.Add();
                dgvInvoices[clmPumpNo.Index, i].Value           = dtInvoice.Rows[i]["PumpNo"].ToString();
                dgvInvoices[clmPumpName.Index, i].Value         = dtInvoice.Rows[i]["PumpName"].ToString();
                dgvInvoices[clmItemName.Index, i].Value         = dtInvoice.Rows[i]["itemname"].ToString();
                dgvInvoices[clmEmpName.Index, i].Value          = dtInvoice.Rows[i]["empname"].ToString();
                dgvInvoices[clmUnitSellingPrice.Index, i].Value = dtInvoice.Rows[i]["unitsellingPrice"].ToString();
                dgvInvoices[clmOldCounter.Index, i].Value       = dtInvoice.Rows[i]["old_counter"].ToString();
                dgvInvoices[clmNewCounter.Index, i].Value       = dtInvoice.Rows[i]["new_counter"].ToString();
                dgvInvoices[clmQty.Index, i].Value = dtInvoice.Rows[i]["qty"].ToString();
                dgvInvoices[clmTotalSellingPrice.Index, i].Value = Convert.ToDouble(dtInvoice.Rows[i]["qty"].ToString()) * Convert.ToDouble(dtInvoice.Rows[i]["unitsellingPrice"].ToString());
            }


            if (UserTemplate.HasPrivilege("btnPrint"))
            {
                btnPrint.Enabled = true;
            }
            else
            {
                btnPrint.Enabled = false;
            }

            btnSave.Enabled = false;
        }
Beispiel #20
0
        private void GetData(string strInvoicePkid)
        {
            btnNew_Click(null, null);
            lstPumps.Items.Clear();
            ConnectionToMySQL cnn       = new ConnectionToMySQL();
            DataTable         dtInvoice = cnn.GetDataTable("select h.pkid, h.stat, h.invoice_no, h.warehouse_id, " +
                                                           " h.pump_emp, h.pump_id, h.emp_id, " +
                                                           " h.old_counter, h.new_counter, h.invoice_note, h.item_id, h.qty, h.unitsellingPrice, " +
                                                           " h.TotalSellingPrice, h.Branch_id, p.PumpName, i.itemno, i.itemname, emp.empname " +
                                                           " from invoice_header h " +
                                                           " join items i on (i.pkid = h.item_id) " +
                                                           " join pumps p on (p.pkid = h.pump_id) " +
                                                           " join emp on (emp.pkid = h.emp_id)" +
                                                           " where h.pkid=" + strInvoicePkid);

            bLoad                      = true;
            txtPkid.Text               = strInvoicePkid;
            txtInvoiceNo.Text          = dtInvoice.Rows[0]["invoice_no"].ToString();
            lstWareHouse.SelectedValue = dtInvoice.Rows[0]["warehouse_id"].ToString();

            lstPumps.Items.Add(dtInvoice.Rows[0]["PumpName"].ToString());
            lstPumps.Text = dtInvoice.Rows[0]["PumpName"].ToString();
            bLoad         = false;

            txtEmpName.Text            = dtInvoice.Rows[0]["empname"].ToString();
            txtItemNo.Text             = dtInvoice.Rows[0]["itemno"].ToString();
            txtItemName.Text           = dtInvoice.Rows[0]["itemname"].ToString();
            nmbOnhandQty.Value         = (decimal)glb_function.GetQty(dtInvoice.Rows[0]["item_id"].ToString(), lstWareHouse.SelectedValue.ToString());
            nmbUnitSellingPrice.Value  = Convert.ToDecimal(dtInvoice.Rows[0]["unitsellingPrice"].ToString());
            nmbPreviousCounter.Value   = Convert.ToDecimal(dtInvoice.Rows[0]["old_counter"].ToString());
            nmbCurrentCounter.Value    = Convert.ToDecimal(dtInvoice.Rows[0]["new_counter"].ToString());
            nmbRequiredQty.Value       = Convert.ToDecimal(dtInvoice.Rows[0]["qty"].ToString());
            nmbTotalSellingPrice.Value = Convert.ToDecimal(dtInvoice.Rows[0]["TotalSellingPrice"].ToString());
            txtInvoiceNote.Text        = dtInvoice.Rows[0]["invoice_note"].ToString();



            if (UserTemplate.HasPrivilege("btnPrint"))
            {
                btnPrint.Enabled = true;
            }
            else
            {
                btnPrint.Enabled = false;
            }

            btnSave.Enabled = false;
        }
Beispiel #21
0
        public ProfilePage(string rvname, int rank)
        {
            var           PlayerWindow = Application.Current.Windows.OfType <PlayerWindow>().LastOrDefault();
            UserGenerator rivalGen     = new UserGenerator(rvname, "...", "Player");

            cUserData = PlayerWindow.cUserData;
            rivalGen.generateRival();
            rivalUserData = rivalGen.getUser();
            rivalUserData.statistics.rank.global = rank;
            DataContext = rivalUserData;
            Console.WriteLine(rvname);
            InitializeComponent();
            b_perf.Visibility = Visibility.Hidden;
            b_stat.Visibility = Visibility.Hidden;
            b_comp.Visibility = Visibility.Visible;
        }
Beispiel #22
0
        private void PrepareForm()
        {
            if (UserTemplate.HasPrivilege("btnSave"))
            {
                btnSave.Enabled = true;
            }


            FillTempletTree();


            btnUpdate.Enabled = false;
            txtPassword.Text  = "123";

            FillBranches();
        }
        public ActionResult SelectTemplate(UserTemplate template)
        {
            string t = Request.Form["Template"];

            // retrieve the template
            //
            var userTemplate = db.UserTemplates.
                               Where(u => u.Name == t).First();

            //Create(userTemplate.UserTemplateID);

            return(RedirectToAction("Create", new { id = userTemplate.UserTemplateID }));


            //return RedirectToAction("ListActiveGames");
        }
Beispiel #24
0
        private void PrepareForm()
        {
            FillData();
            txtCreditTotal.Text     = "0";
            txtDeptTotal.Text       = "0";
            txtDeptTotal.Background = txtCreditTotal.Background = Brushes.LawnGreen;
            if (UserTemplate.HasPrivilege("btnSave"))
            {
                btnSave.IsEnabled = true;
            }
            else
            {
                btnSave.IsEnabled = false;
            }

            btnUpdate.IsEnabled = false;
        }
Beispiel #25
0
        public async Task <ResponseMessage <int> > AddUserTemplate([FromBody] UserTemplate userTemplate)
        {
            ResponseMessage <int> Response = new ResponseMessage <int>();

            if (userTemplate == null)
            {
                Response.Msg  = "userTemplate is null.";
                Response.Code = ResponseCodeDefines.ArgumentNullError;
                return(Response);
            }
            if (userTemplate.TemplateID > 0)
            {
                Response.Msg  = "Template ID is larger than 0";
                Response.Code = ResponseCodeDefines.ArgumentNullError;
                return(Response);
            }
            if (userTemplate.UserCode == string.Empty ||
                userTemplate.TemplateName == string.Empty)
            {
                Response.Msg  = "UserCode or TemplateName is null.";
                Response.Code = ResponseCodeDefines.ArgumentNullError;
                return(Response);
            }
            try
            {
                Response.Ext = await _GlobalManager.UserTemplateInsertAsync(userTemplate.TemplateID, userTemplate.UserCode, userTemplate.TemplateName, userTemplate.TemplateContent);

                Response.Code = ResponseCodeDefines.SuccessCode;
            }
            catch (System.Exception e)
            {
                if (e.GetType() == typeof(SobeyRecException))//sobeyexcep会自动打印错误
                {
                    SobeyRecException se = e as SobeyRecException;
                    Response.Code = se.ErrorCode.ToString();
                    Response.Msg  = se.Message;
                }
                else
                {
                    Response.Code = ResponseCodeDefines.ServiceError;
                    Response.Msg  = "error info:" + e.ToString();
                    Logger.Error(Response.Msg);
                }
            }
            return(Response);
        }
Beispiel #26
0
        public JsonResult GetAllUsers(string email, string password)
        {
            JavaScriptSerializer sr = new JavaScriptSerializer();

            var userList     = FindEducatorsRepository.GetAllUsers();
            var usertemplate = new List <UserTemplate>();

            foreach (var user in userList)
            {
                var temp = new UserTemplate();
                temp.UserId   = user.Id;
                temp.UserName = user.FirstName;

                usertemplate.Add(temp);
            }

            return(Json(sr.Serialize(usertemplate), JsonRequestBehavior.AllowGet));
        }
Beispiel #27
0
        public ActionResult DeleteConfirmed(int id)
        {
            UserTemplate userTemplate    = db.UserTemplates.Find(id);
            string       sessionUserName = Session["UserName"].ToString();
            var          user            = db.Users.
                                           Where(u => u.Email == sessionUserName).
                                           First();

            if (sessionUserName != null && user != null)
            {
                if (user.UserID == userTemplate.UserID)
                {
                    db.UserTemplates.Remove(userTemplate);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            return(View());
        }
Beispiel #28
0
    public EndpointUrlBuilder(ManagementOptions options)
    {
        _taxonomyTemplate       = new TaxonomyTemplate();
        _assetTemplate          = new AssetTemplate();
        _assetRenditionTemplate = new AssetRenditionTemplate();
        _languageTemplate       = new LanguageTemplate();
        _snippetTemplate        = new SnippetTemplate();
        _collectionTemplate     = new CollectionTemplate();
        _typeTemplate           = new TypeTemplate();
        _validateTemplate       = new ValidateTemplate();
        _variantTemplate        = new VariantTemplate();
        _webhookTemplate        = new WebhookTemplate();
        _workflowTemplate       = new WorkflowTemplate();
        _itemTemplate           = new ItemTemplate();
        _projectRolesTemplate   = new ProjectRolesTemplate();
        _userTemplate           = new UserTemplate();

        _options = options;
    }
Beispiel #29
0
    public async Task <IActionResult> Get(string name)
    {
        ObjectId id = await database.GetUserCollection().GetByName(name);

        if (id != ObjectId.Empty)
        {
            UserModel model = await database.GetUserCollection().GetUserInfo(id);

            UserTemplate template = new UserTemplate {
                id          = model.id.ToString(),
                username    = model.username,
                loginStatus = model.loginStatus
            };

            return(Json(template));
        }

        return(BadRequest($"user with name: {name}, does not exist"));
    }
Beispiel #30
0
        public async Task AllUsers_UseComplexData_ReuseTemplate()
        {
            UserTemplate user = new UserTemplate
            {
                { "FirstName", "Jamie" }
            };

            UserWithAddressTemplate userWithAddress = new UserWithAddressTemplate
            {
                User = user
            };
            await TestRunner.InsertTemplateAsync(userWithAddress);

            await TestRunner.InsertTemplateAsync(user);

            QueryResult results = await TestRunner.ExecuteViewAsync("dbo.AllUsers");

            results
            .AssertRowCount(1);
        }
Beispiel #31
0
        public async Task <UserTemplateDTO> Delete(Guid id)
        {
            try
            {
                UserTemplate template = await this._repo.GetById(id);

                if (template == null)
                {
                    return(null);
                }
                await this._repo.Delete(template);

                UserTemplateDTO dto = new UserTemplateDTO(template._tid, template.attributes);
                return(dto);
            }
            catch (System.Exception)
            {
                throw new Exception("Internal error deleting an existing User Template");
            }
        }
Beispiel #32
0
        public async Task <UserTemplateDTO> Create(string email, CreateTemplateCommand command)
        {
            try
            {
                Organization org = await this._orgService.GetByEmail(email);

                UserTemplate template        = new UserTemplate(org, command.attributes);
                UserTemplate createdTemplate = await this._repo.Create(template);

                org.associateTemplate(createdTemplate);
                await this._orgService.Update(org);

                UserTemplateDTO dto = new UserTemplateDTO(createdTemplate._tid, createdTemplate.attributes);
                return(dto);
            }
            catch (Exception)
            {
                throw new Exception("Internal error creating a User Template");
            }
        }
Beispiel #33
0
        public void WeekMostOnlineUserList(int count, UserTemplate template)
        {
            UserCollection users = UserBO.Instance.GetMostActiveUsers(ActiveUserType.WeekOnlineTime, count);

            template(users);
        }
Beispiel #34
0
        public static User NewUser(UserTemplate usertemplate)
        {
            User usr = null;

            try
            {
                SqlConnection connection;
                SqlCommand cmd;

                // create user
                string query = "INSERT INTO [User] (Username,PIN,Password,LockID,IsAdministrator,IsEnabled) VALUES (" +
                    "'"+usertemplate.Username+"'," +
                    "'"+usertemplate.PIN+"'," +
                    "'" + usertemplate.Password + "'," +
                    "'" + usertemplate.LockID + "'," +
                    "'" + usertemplate.IsAdministrator.ToString() + "'," +
                    "'" + usertemplate.IsEnabled.ToString() + "'" +
                    ")";
                connection = new SqlConnection(ConnectionString);
                cmd = new SqlCommand(query, connection);
                connection.Open();
                cmd.ExecuteNonQuery();
                connection.Close();

                // get user object for return value
                usr = GetUser(usertemplate.Username);
            }
            catch (Exception ex)
            {
                string errmsg = "Fehler beim Erstellen des Benutzerprofils.\n\n";
                errmsg += "DatabaseHandler.NewUser(usertemplate): " + ex.ToString();
                throw new Exception(errmsg);
            }

            if(usr == null)
                throw new Exception("Fehler beim Erstellen des Benutzerprofils. Das Speichern konnte nicht verifiziert werden.\n\nDatabaseHandler.NewUser(usertemplate)");

            return usr;
        }
Beispiel #35
0
 private static async Task CreateUserSync(UserManager<ApplicationUser> userManager, UserTemplate userTemplate, ApplicationUser user)
 {
     await userManager.CreateAsync(user, userTemplate.Password);
     await userManager.AddToRolesAsync(user, userTemplate.Roles);
 }
Beispiel #36
0
        public void DayMostPostUserList(int count, UserTemplate template)
        {
            UserCollection users = UserBO.Instance.GetMostActiveUsers(ActiveUserType.DayPosts, count);

            template(users);
        }