public static DAL.Shelter DtoToDAL(ShelterDTO shelterDTO) { DAL.Shelter shelterDAL = new DAL.Shelter(); shelterDAL.ShelterKey = shelterDTO.ShelterKey; shelterDAL.LatShelter = shelterDTO.LatShelter; shelterDAL.LngShelter = shelterDTO.LngShelter; shelterDAL.MaxPeople = shelterDTO.MaxPeople; shelterDAL.ShelterDescription = shelterDTO.ShelterDescription; return(shelterDAL); }
public static DAL.Shelter DtoToDAL(ShelterDTO shelterDTO) { DAL.Shelter shelterDAL = new DAL.Shelter(); shelterDAL.ShelterKey = shelterDTO.ShelterKey; shelterDAL.City = shelterDTO.City; shelterDAL.ShelterStreet = shelterDTO.ShelterStreet; shelterDAL.StreetNumber = shelterDTO.StreetNumber; shelterDAL.MaxPeople = shelterDTO.MaxPeople; shelterDAL.ShelterDescription = shelterDTO.ShelterDescription; return(shelterDAL); }
public static ShelterDTO AddNewShelter(ShelterDTO newShelter, ref string message) { DAL.Shelter ifLatExists = db.Shelters.FirstOrDefault(s => s.LatShelter == newShelter.LatShelter); DAL.Shelter ifLngExists = db.Shelters.FirstOrDefault(s => s.LngShelter == newShelter.LngShelter); if (ifLatExists != null && ifLngExists != null) { message = "מקלט זה קיים במערכת"; return(null); } DAL.Shelter shelterDAL = DtoToDAL(newShelter); db.Shelters.Add(shelterDAL); db.SaveChanges(); return(newShelter); }