public ActionResult CreateStaff()
 {var data = new AccountCreateViewModel();
     var listgroup = new List<SelectListItem>();
     
     var count = AccountDAO.Current.GetCountMemberOfGroup();
     for (int i = 0; i < count.Count; i++)
     {
         var list = new SelectListItem();
         if (count[i].CountMember < 3 && count[i].GroupCode!="Admin")
         {
             list.Value = count[i].GroupCode;
             list.Text = count[i].GroupCode;
             listgroup.Add(list);
         }
         
     }
     data.Groups = listgroup;
     return View(data);
 }
 public ActionResult CreateStaff(AccountCreateViewModel accountCreateViewModel)
 {
     if (ModelState.IsValid)
     {
         var account = Mapper.Map<AccountCreateViewModel, Account>(accountCreateViewModel);
         account.Status = true;
         account.Password = AccountBLO.Current.GeneratePassword();
         AccountBLO.Current.Add(account);
         //send account info to login to the system
         AccountBLO.Current.SendAccountInfo(account);
         
         return RedirectToAction("Index", new {Message ="New Staff was added!"});
     }
     return RedirectToAction("Index");
 }
  public ActionResult EditStaff(AccountCreateViewModel viewmodel)
  {
      var account = AccountBLO.Current.GetAccountByCode(viewmodel.Username);
      account.GroupCode = viewmodel.GroupCode;
      account.Role = viewmodel.Role;
      account.Fullname = viewmodel.Fullname;
      account.Phone = viewmodel.Phone;
      account.Address = viewmodel.Address;
      account.Identification = viewmodel.Identification;
      account.Email = viewmodel.Email;
      AccountBLO.Current.Update(account);
 
      return RedirectToAction("ViewProfile", new { username = viewmodel.Username, Message ="Profile was updated!" });
  }
        public ActionResult ViewProfile(AccountCreateViewModel acvm)
        {
            var mess = "";
            if (acvm.Button == "Deactivate")
            {
            
                var account = AccountBLO.Current.GetAccountByCode(acvm.Username);
                account.Status = false;
                AccountBLO.Current.Update(account);
                mess = "Account was deativated!";
            }
            if (acvm.Button == "Activate")
            {
                var account = AccountBLO.Current.GetAccountByCode(acvm.Username);
                account.Status = true;
                AccountBLO.Current.Update(account);
                mess = "Account was activated!";
            }

        return RedirectToAction("ViewProfile", new {username = acvm.Username, Message = mess});
        }
 public ActionResult EditAccount(AccountCreateViewModel acvm)
 {
     var account = AccountBLO.Current.GetAccountByCode(acvm.Username);
     account.Address = acvm.Address;
     account.Email = acvm.Email;
     account.Fullname = acvm.Fullname;
     account.Company = acvm.Company;
     account.Identification = acvm.Identification;
     account.Phone = acvm.Phone;
     AccountBLO.Current.Update(account);
  
     return RedirectToAction("ViewProfile", new {username = acvm.Username, Message ="Profile was updated!"});
 }