private bool _IsValid(string login, string password)
        {
            PETianoFilter petianoFilter = new PETianoFilter()
            {
                Login = login
            };

            PETiano user = _PETianoService.GetPETiano(petianoFilter);

            if (user != null && Crypto.VerifyHashedPassword(user.Password, password))
                return true;
            else
                return false;
        }
        public ActionResult Delete(int id)
        {
            PETianoFilter petianoFilter = new PETianoFilter()
            {
                Id = id
            };

            PETiano petiano = _PETianoService.GetPETiano(petianoFilter);

            if (petiano != null)
                return View(petiano);
            else
                return View();
        }
        public ActionResult Edit(int id)
        {
            PETianoFilter petianoFilter = new PETianoFilter()
            {
                Id = id
            };

            PETiano petiano = _PETianoService.GetPETiano(petianoFilter);
            petiano.Password = Crypto.Hash(petiano.Password);

            if (petiano == null)
                return View();

            return View(petiano);
        }
        private void _PopulateDropdown(string typeDropdown)
        {
            List<string> type = new List<string>();

            foreach (Enum value in Enum.GetValues(typeof(EFeedbackType)))
                type.Add(value.GetDescription());

            if (string.IsNullOrEmpty(typeDropdown))
                ViewBag.FeedbackTypeDropdown = new SelectList(type);
            else
                ViewBag.FeedbackTypeDropdown = new SelectList(type, typeDropdown);

            PETianoFilter petianoFilter = new PETianoFilter()
            {
                notThisId = LoggedPETiano.GetLogedPETiano().Id
            };

            ViewBag.PETianos = this._PETianoService.GetPETianos(petianoFilter).Select(petiano => new SelectListItem
            {
                Text = petiano.Name + "(" + petiano.Login + ")",
                Value = petiano.Id.ToString()
            });
        }
 public List<PETiano> GetPETianos(PETianoFilter petianoFilter = null)
 {
     using (IDataProvider provider = base.CreateDataProvider())
     using (IPETianoRepository repository = provider.CreatePETianoRepository())
         return repository.GetPETianos(petianoFilter);
 }
 public List<PETiano> GetPETianos(PETianoFilter petianoFilter = null)
 {
     using (IBusinessProvider provider = base.CreateBusinessProvider())
     using (IPETianoBusinessProvider prov = provider.CreatePETianoBusinessProvider())
         return prov.GetPETianos(petianoFilter);
 }
        public ActionResult Edit(PETiano petiano, string profile)
        {
            if (string.IsNullOrEmpty(petiano.Name) || string.IsNullOrEmpty(petiano.Login) || string.IsNullOrEmpty(petiano.Password))
            {
                PETianoFilter petianoFilter = new PETianoFilter()
                {
                    Id = petiano.Id
                };

                PETiano ptn = _PETianoService.GetPETiano(petianoFilter);

                if (ptn == null)
                    return View();

                ptn.Password = string.Empty;

                _PopulateDropdown(ptn.Profile.GetDescription());

                return View(ptn);
            }

            petiano.Password = Crypto.HashPassword(petiano.Password);

            if (petiano.PhotoFile != null)
            {
                using (MemoryStream target = new MemoryStream())
                {
                    petiano.PhotoFile.InputStream.CopyTo(target);
                    petiano.Photo = target.ToArray();
                }
            }

            petiano.Profile = Extension.GetValueFromDescription<EProfile>(profile);

            _SendEmailProfile(Extension.GetValueFromDescription<EProfile>(profile), true);

            this._PETianoService.EditPETiano(petiano);

            return RedirectToAction("Index");
        }