Ejemplo n.º 1
0
 public Result <bool> AddResident(Resident resident)
 {
     try
     {
         resident.IsActive = true;
         _dbContext.Residents.Add(resident);
         if (_dbContext.SaveChanges() > 0)
         {
             return(Result <bool> .Success(true, Constants.RESIDENT_ADD_SUCCESS));
         }
         return(Result <bool> .Fail(Constants.ERROR));
     } catch (Exception ex)
     {
         throw ex;
     }
 }
        public Result <bool> AddUser(User user)
        {
            user.IsActive = true;
            User userData = _dbContext.Users.Where(p => p.Email == user.Email && p.IsActive == true).FirstOrDefault();

            if (userData == null)
            {
                _dbContext.Users.Add(user);
                if (_dbContext.SaveChanges() > 0)
                {
                    string subject = "Manage Condo Credentials";
                    string message = "Manage Condo Credentials - Email: " + user.Email + " Password: " + user.Password;
                    Email.SendMail(user.Email, subject, message);
                    return(Result <bool> .Success(true, Constants.USER_ADD_SUCCESS));
                }
            }
            else
            {
                return(Result <bool> .Fail(Constants.USER_EXISTS));
            }
            return(Result <bool> .Fail(Constants.ERROR));
        }
Ejemplo n.º 3
0
        public Result <bool> AddParcel(Parcel parcel)
        {
            try
            {
                User     user     = _dbContext.Users.Where(r => r.IsActive == true && r.ID == parcel.Resident.User.ID).FirstOrDefault();
                Resident resident = _dbContext.Residents.Where(r => r.IsActive == true && r.UserID == user.ID).FirstOrDefault();

                parcel.IsActive   = true;
                parcel.Resident   = resident;
                parcel.ResidentID = resident.ID;

                _dbContext.Parcels.Add(parcel);
                if (_dbContext.SaveChanges() > 0)
                {
                    return(Result <bool> .Success(true, Constants.PARCELS_ADD_SUCCESS));
                }
                return(Result <bool> .Fail(Constants.ERROR));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void AddUnit(Unit unit)
 {
     unit.IsActive = true;
     _dbContext.Units.Add(unit);
     _dbContext.SaveChanges();
 }
 public void AddProperty(Property property)
 {
     property.IsActive = true;
     _dbContext.Properties.Add(property);
     _dbContext.SaveChanges();
 }