예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ClientId,Name,Lastname,Email,Password,ProfilePicture,TypeOfUser")] RoomOwner owner)
        {
            if (owner.OwnerId == null)
            {
                NotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _dbContext.Update(owner);
                    await _dbContext.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (owner.OwnerId == null)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Login)));
            }
            return(View(owner));
        }
예제 #2
0
        public IActionResult Create(RoomOwner owner)
        {
            if (ModelState.IsValid)
            {
                owner.OwnerId = _ownerService.GenerateIdRandom(owner.OwnerId);
                if (owner.OwnerId != null)
                {
                    var result = _ownerService.IfEmailExist(owner.Email);
                    if (result == false)
                    {
                        owner.Password   = _ownerService.EncryptPassword(Encoding.UTF8, owner.Password);
                        owner.TypeOfUser = 1;
                        _ownerService.Create(owner);
                        HttpContext.Session.SetString("Name", owner.Name + " " + owner.Lastname);
                        HttpContext.Session.SetString("Id", owner.OwnerId);

                        return(RedirectToAction(nameof(Index)));
                    }
                    else
                    {
                        ModelState.AddModelError("Email", _localizer["Now this email is used, please enter a new!"].ToString());
                        return(View(owner));
                    }
                }
            }
            return(View(owner));
        }
예제 #3
0
 public IActionResult Dashboard(RoomOwner owner)
 {
     if (owner.Email == null)
     {
         NotFound();
     }
     return(View(_dbContext.RoomOwners.Where(x => x.Email == owner.Email)));
 }
예제 #4
0
        public IActionResult Login(RoomOwner owner)
        {
            //_ownerService.EncryptPassword(Encoding , owner.Password);
            var result = _ownerService.Login(owner.Email, owner.Password);

            if (ModelState.IsValid)
            {
                if (result == null)
                {
                    ModelState.AddModelError("Password", _localizer["Email or password are wrong, enter again"].ToString());
                    return(View(result));
                }
                else
                {
                    HttpContext.Session.SetString("Name", result.Name + " " + result.Lastname);
                    HttpContext.Session.SetString("Id", result.OwnerId);
                    return(RedirectToAction("Index"));
                }
            }
            return(View(owner));
        }
예제 #5
0
 public IActionResult Create(RoomOwner owner)
 {
     if (ModelState.IsValid)
     {
         owner.OwnerId = _ownerService.GenerateIdRandom(owner.OwnerId);
         if (owner.OwnerId != null)
         {
             var result = _ownerService.IfEmailExist(owner.Email);
             if (result == false)
             {
                 owner.Password = _ownerService.EncryptPassword(Encoding.UTF8, owner.Password);
                 _ownerService.Create(owner);
             }
             else
             {
                 ModelState.AddModelError("Email", _localizer["Now this email is used, please enter a new!"].ToString());
                 return(View(owner));
             }
         }
         return(RedirectToAction("HomePage", owner));
     }
     return(View(owner));
 }