예제 #1
0
        public async Task <ActionResult> Create(ClientUserRoleDTO client)
        {
            var errors = ModelState
                         .Where(x => x.Value.Errors.Count > 0)
                         .Select(x => new { x.Key, x.Value.Errors })
                         .ToArray();

            if (ModelState.IsValid)
            {
                try
                {
                    string roleId   = GetRoleIdOfClient();
                    string email    = client.Email;
                    string password = client.Password;
                    string userName = email;
                    // string roleName = collection["Name";
                    bool emailConfirmed       = false;
                    bool phoneNumberConfirmed = false;
                    bool twoFactorEnabled     = false;
                    bool lockoutEnabled       = false;
                    int  accesFailedCount     = 0;
                    //ovo gore dobro pokupi i sada trebam da ovog klijenta posaljem da kreira Identity i onda taj vraceni ID->upisem tog korisnika!!!
                    //////////////////////
                    string   firstName        = client.FirstName;
                    string   lastName         = client.LastName;
                    DateTime registrationDate = client.RegistrationDate;
                    DateTime dateOfBirth      = client.DateOfBirth;
                    string   description      = client.Description;

                    //////////////////////////
                    await clientDAO.Create(firstName, lastName, dateOfBirth, registrationDate, roleId, email, userName, password, emailConfirmed, phoneNumberConfirmed, twoFactorEnabled, lockoutEnabled, accesFailedCount, description);



                    return(RedirectToAction("Index"));
                    //return RedirectToAction("Details", new { id = id });
                }
                catch (Exception e)
                {
                    return(View("Error"));
                }
            }
            else
            {
                return(View("Create"));
            }
        }
예제 #2
0
        public ActionResult Save(Client client)
        {
            if (!ModelState.IsValid)
            {
                return(View("ClientAdd", client));
            }

            var clientId = int.Parse(Request["clientID"]);

            client.ClientId = clientId;

            if (client.ClientId == 0)
            {
                ClientDAO.Create(client);
            }
            else
            {
                ClientDAO.Update(client);
            }

            return(RedirectToAction("ClientList"));
        }
예제 #3
0
 public string Create(Client client)
 {
     ClientDAO.Create(client);
     return("Client Created");
 }