Ejemplo n.º 1
0
 /// <summary>
 /// Add the House Record to DataBase
 /// </summary>
 /// <param name="houseListingDTO"></param>
 /// <returns></returns>
 public HouseListingDTO AddHouseListingDAL(HouseListingDTO houseListingDTO)
 {
     try
     {
         using (CensusDataDigitalizationContext db = new CensusDataDigitalizationContext())
         {
             HouseListingEntity houseListingEntity        = mapHouseListingDTO2Entity.Map <HouseListingEntity>(houseListingDTO);
             HouseListingEntity createdHouseListingEntity = db.HouseListingEntity.Add(houseListingEntity);
             db.SaveChanges();
             HouseListingDTO createdHouseListingDTO = mapHouseListingEntity2DTO.Map <HouseListingDTO>(createdHouseListingEntity);
             return(createdHouseListingDTO);
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(e);
         return(null);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Add a new User to DataBase
 /// </summary>
 /// <param name="userDTO"></param>
 /// <returns></returns>
 public UserDTO AddUserDAL(UserDTO userDTO)
 {
     try
     {
         using (CensusDataDigitalizationContext db = new CensusDataDigitalizationContext())
         {
             UserEntity userEntity;
             userEntity = mapUserDTO2Entity.Map <UserEntity>(userDTO);
             UserEntity createdUserEntity = db.UserEntity.Add(userEntity);
             db.SaveChanges();
             UserDTO createdUserDTO = mapUserEntity2DTO.Map <UserDTO>(createdUserEntity);
             return(createdUserDTO);
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(e);
         return(null);
     }
 }
 /// <summary>
 /// Add Population Details to DataBase.
 /// </summary>
 /// <param name="populationRegistrationDTO"></param>
 /// <returns></returns>
 public PopulationRegistrationDTO AddPopulationDAL(PopulationRegistrationDTO populationRegistrationDTO)
 {
     try
     {
         using (CensusDataDigitalizationContext db = new CensusDataDigitalizationContext())
         {
             PopulationRegistrationEntity populationEntity;
             populationEntity = mapPopulationRegistrationDTO2Entity.Map <PopulationRegistrationEntity>(populationRegistrationDTO);
             PopulationRegistrationEntity createdPopulationRegistrationEntity = db.PopulationRegistrationEntity.Add(populationEntity);
             db.SaveChanges();
             PopulationRegistrationDTO createdUserDTO = mapPopulationRegistrationEntity2DTO.Map <PopulationRegistrationDTO>(createdPopulationRegistrationEntity);
             return(createdUserDTO);
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(e);
         return(null);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Update User's Request Status in Database
        /// </summary>
        /// <param name="id"></param>
        /// <param name="stat"></param>
        /// <returns></returns>
        public UserDTO UpdateUserDAL(int id, ApprovalStatus stat)
        {
            using (CensusDataDigitalizationContext db = new CensusDataDigitalizationContext())
            {
                try
                {
                    UserEntity user = db.UserEntity.Find(id);
                    user.IsApproved = stat;
                    //db.UserEntity.Add(user);
                    db.SaveChanges();
                    UserDTO userDTO = mapUserEntity2DTO.Map <UserDTO>(user);

                    return(userDTO);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e);
                    return(null);
                }
            }
        }