public GeoLocalization(string fullLocation, DistrictEnum district)
 {
     //if (FullAdress != null && FullAdress != "")
         // => Reverse GeoCoordinate
         // Coordinate = new GeoCoordinate(latitude, longitude);
         District = district;
         FullAdress = fullLocation;
 }
示例#2
0
 public User(string username, string password, string email, DistrictEnum district, String fullName, int? pnr = null)
 {
     Username = username;
     Password = password;
     Email = email;
     FullName = fullName;
     PhoneNr = pnr;
     District = district;
     Ads = new LinkedList<int>();
     RegisterDate = DateTime.Now;
 }
        public ActionResult Edit(String Password, String newPassword, string fullName, string email, int? phoneNr, DistrictEnum? district, bool? isStand, string standLink, string fullAdress)
        {
            User activeUser = _userLogic.GetUserById(User.Identity.Name);
            if (Password.IsNullOrWhiteSpace() || !activeUser.Password.Equals(Password)) //obrigatorio
            {
                ModelState.AddModelError("badPassword", "Password errada!");
                return RedirectToAction("Edit");
            }

            if (!newPassword.IsNullOrWhiteSpace() && activeUser.Password != newPassword)
                activeUser.Password = newPassword;
            if (!fullName.IsNullOrWhiteSpace() && activeUser.FullName != fullName)
                activeUser.FullName = fullName;
            if (!email.IsNullOrWhiteSpace() && activeUser.FullName != fullName)
                activeUser.Email = email;
            if (phoneNr.HasValue && activeUser.PhoneNr != phoneNr)
                activeUser.PhoneNr = phoneNr.Value;
            if (district.HasValue && activeUser.District != district)
                activeUser.District = district.Value;
            if (isStand.HasValue && activeUser.IsStand != isStand)
                activeUser.IsStand = isStand.Value;

            if (activeUser.IsStand) // TODO verificar se checkbox está activo
            {
                if (!standLink.IsNullOrWhiteSpace() && activeUser.StandLink != standLink)
                    activeUser.StandLink = standLink;

                if (!fullAdress.IsNullOrWhiteSpace() && activeUser.GeoLocalization.FullAdress != fullAdress)
                    activeUser.GeoLocalization.FullAdress = fullAdress;
            }

            if (!_userLogic.UpdateUser(activeUser))
                ModelState.AddModelError("AccountUpdateError", "Erro! Não foi possível editar esta conta!");
            return RedirectToAction("Index");
        }