public User Map(UserCreateViewModel source, User destination)
        {
            if (source == null)
            {
                return null;
            }

            if (destination == null)
            {
                destination = new User();
            }

            destination.UserName = source.UserName;
            destination.FirstName = source.FirstName;
            destination.LastName = source.LastName;
            destination.Password = source.Password;
            destination.Email = source.Email;
            destination.Country = source.Country;
            destination.City = source.City;
            destination.StreetRow = source.StreetRow;
            destination.Phone = source.Phone;

            if (destination.Roles == null)
            {
                destination.Roles = new List<Role>();
            }

            return destination;
        }
        public virtual ActionResult CreateUser(UserCreateViewModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                try
                {
                    var existing = userService.GetUserByUsername(model.UserName);

                    if (existing == null)
                    {
                        var user = ViewModelToEntityMapper.Mapper.Map(model, new User());

                        var roles = userService.GetAllRoles();
                        
                        if (roles != null && roles.Count > 0)
                        {
                            if (model.IsAdmin)
                            {
                                user.Roles.Add( roles.Find(x => x.Id == (int)UserRoleEnum.Admin ));
                            }
                            if (model.IsWorker)
                            {
                                user.Roles.Add(roles.Find(x => x.Id == (int)UserRoleEnum.Worker));
                            }
                        }
                        

                        user = userService.CreateUser(user);
                    }
                    else
                    {
                        ModelState.AddModelError("UserName", "Vartotojo vardas jau yra sistemoje, pasirinkite kitą.");
                    }
                }
                catch (Exception ex)
                {
                    
                }
                
            }

            return View(model);
        }
 public virtual ActionResult CreateUser()
 {
     var model = new UserCreateViewModel();
     return View(model);
 }