public Apartment AddApartment([FromBody] Apartment apartment) { string userName = ((ClaimsIdentity)User.Identity).FindFirst("UserName").Value; int role = Int32.Parse(((ClaimsIdentity)User.Identity).FindFirst("Role").Value); if (apartment.CategoryID < 1 || apartment.CategoryID > 2 || apartment.CountryID < 1 || apartment.CountryID > 5 || apartment.PricePerDay < 0 || apartment.Address.Length > 50 || apartment.Address.Length < 5 || String.IsNullOrEmpty(apartment.Address) || apartment.FromDate.Ticks >= apartment.ToDate.Ticks || presentTicks > apartment.FromDate.Ticks || presentTicks >= apartment.ToDate.Ticks || apartment.Description.Length > 70 || apartment.Description.Length < 5 || String.IsNullOrEmpty(apartment.Description) || apartment.NumberOfGuests < 1 || apartment.NumberOfGuests > 20 || apartment.NumberOfBedRooms < 1 || apartment.LivingRoomDescription.Length > 70 || apartment.LivingRoomDescription.Length < 5 || String.IsNullOrEmpty(apartment.LivingRoomDescription) || apartment.BedRoomDescription.Length > 70 || apartment.BedRoomDescription.Length < 5 || String.IsNullOrEmpty(apartment.BedRoomDescription) || apartment.QueenSizeBed < 0 || apartment.DoubleBed < 0 || apartment.SingleBed < 0 || apartment.SofaBed < 0 || apartment.BedsDescription.Length > 70 || apartment.BedsDescription.Length < 5 || String.IsNullOrEmpty(apartment.BedsDescription)) { return(null); } if (apartment.ApartmentImageType[0] != null) { apartment.ApartmentImageByte = ImageValidation.Base64Vadilation(null, apartment.ApartmentImage); } if (apartment.ApartmentImageByte[0] == null) { return(null); } bool changeRenterStatus = false; if (role == 0) { changeRenterStatus = true; } return(DB.ApartmentDB.AddApartment(apartment, userName, changeRenterStatus)); }
public bool UpdateProfileImage([FromBody] Users user) { user.UserName = ((ClaimsIdentity)User.Identity).FindFirst("UserName").Value; user.ProfileImageByte = ImageValidation.Base64Vadilation(user.ProfileImage, null)[0]; if (user.ProfileImageByte == null || user.ProfileImageType == null || user.ProfileImageType.Length > 50) { return(false); } return(DB.UsersDB.UpdateProfilePicture(user)); }
public bool SignUp([FromBody] Users user) { if (String.IsNullOrEmpty(user.UserName) || String.IsNullOrEmpty(user.Password) || String.IsNullOrEmpty(user.PhoneNumber) || String.IsNullOrEmpty(user.Email) || String.IsNullOrEmpty(user.Address) || String.IsNullOrEmpty(user.FirstName) || String.IsNullOrEmpty(user.LastName) || user.CountryID > 5 || user.CountryID < 1 || user.Address.Length > 50 || user.Address.Length < 3 || user.PhoneNumber.Length > 15 || user.PhoneNumber.Length < 5 || user.UserName.Length > 10 || user.UserName.Length < 4 || user.Password.Length > 10 || user.Password.Length < 6 || user.Email.Length > 30 || user.Email.Length < 7 || user.FirstName.Length > 11 || user.LastName.Length > 11 || !user.Email.Contains(".com") || !user.Email.Contains("@") || String.IsNullOrEmpty(user.ProfileImageType) || user.ProfileImageType.Length > 50) { return(false); } if (!String.IsNullOrEmpty(user.ProfileImage)) { user.ProfileImageByte = ImageValidation.Base64Vadilation(user.ProfileImage, null)[0]; } PasswordHash hash = new PasswordHash(); user.Password = hash.Hash(user.Password); return(DB.UsersDB.SignUp(user)); }
public bool UpdateApartmentImages([FromBody] Apartment apartment) { apartment.RenterUserName = ((ClaimsIdentity)User.Identity).FindFirst("UserName").Value; int role = Int32.Parse(((ClaimsIdentity)User.Identity).FindFirst("Role").Value); if (role != 1 || String.IsNullOrEmpty(apartment.RenterUserName)) { return(false); } apartment.ApartmentImageByte = ImageValidation.Base64Vadilation(null, apartment.ApartmentImage); if (apartment.ApartmentImageByte[0] == null || apartment.ApartmentImageType[0] == null) { return(false); } for (int i = 1; i < 5; i++) { if (apartment.ApartmentImageType[i] == null || apartment.ApartmentImageByte[i] == null) { apartment.ApartmentImageType[i] = null; apartment.ApartmentImageByte[i] = null; } } return(DB.ApartmentDB.UpdateApartmentPictures(apartment)); }