/// <summary> /// Private Method Of Class which checks null or whitespace entries /// </summary> /// <param name="house"></param> /// <returns> wheather there were any null values or not</returns> private bool CheckNullEntries(HouseListingDto house) { if (string.IsNullOrWhiteSpace(house.ApartmentNumber) || string.IsNullOrWhiteSpace(house.City) || string.IsNullOrWhiteSpace(house.HeadName) || string.IsNullOrWhiteSpace(house.State) || string.IsNullOrWhiteSpace(house.StreetNumber)) { return(false); } return(true); }
/// <summary> /// Adding New House /// </summary> /// <param name="house"></param> /// <returns> return wheather house was successfully added or not</returns> public HouseListingDto Add(HouseListingDto house) { if (CheckNullEntries(house)) { HouseListing newHouse = mapper.Mapper.Map <HouseListing>(house); return(mapper.Mapper.Map <HouseListingDto>(houseListingRepository.Add(newHouse))); } return(null); }
//Register House public bool RegisterHouse(HouseListingDto house) { appContext.Database.Log = s => { System.Diagnostics.Debug.WriteLine(s); }; try { houseEntity = mapper.Map <HouseListing>(house); appContext.HouseListing.Add(houseEntity); appContext.SaveChanges(); return(true); } catch (Exception) { return(false); } }
// POST: api/HouseListing public HttpResponseMessage Post([FromBody] HouseListingDto house) { ResponseFormat <HouseListingDto> response = new ResponseFormat <HouseListingDto>(); response.Data = houseListingService.Add(house); if (response.Data != null) { response.message = "New Home Added"; response.success = true; return(Request.CreateResponse(HttpStatusCode.OK, response)); } response.message = "Cannot Enter Data To Home"; response.success = false; return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public bool RegisterHouse(HouseListingDto house) { logger.Info(Constant.Messages.BllHouseRegister); return(houseDal.RegisterHouse(house)); }