private void LoadPetInfo(DTOPet dtoPet) { if (dtoPet.Breed != null && !string.IsNullOrWhiteSpace(dtoPet.Breed.Id)) { var getBreedByIdResult = _breedDomain.GetById(dtoPet.Breed.Id); if (getBreedByIdResult.Code == 200) { dtoPet.Breed = getBreedByIdResult.Data; } } if (dtoPet.FurColor != null && !string.IsNullOrWhiteSpace(dtoPet.FurColor.Id)) { var getFurColorByIdResult = _furColorDomain.GetById(dtoPet.FurColor.Id); if (getFurColorByIdResult.Code == 200) { dtoPet.FurColor = getFurColorByIdResult.Data; } } if (dtoPet.Coat != null && !string.IsNullOrWhiteSpace(dtoPet.Coat.Id)) { var getCoatByIdResult = _coatDomain.GetById(dtoPet.Coat.Id); if (getCoatByIdResult.Code == 200) { dtoPet.Coat = getCoatByIdResult.Data; } } }
public DTOResponse <DTOPet> Create(DTOPet createPetInfo) { if (string.IsNullOrWhiteSpace(createPetInfo.UserId)) { return(new DTOResponse <DTOPet>() { Code = 400, Message = "User Id is required!" }); } var petModel = createPetInfo.ToModel(); _petCollection.InsertOne(petModel); return(new DTOResponse <DTOPet>() { Code = 200 }); }
public static PetModel ToModel(this DTOPet dto) { return(new PetModel() { Id = dto.Id, UserId = dto.UserId, Type = (int)dto.Type, Name = dto.Name, Weight = dto.Weight, Birthdate = dto.Birthdate, DistinctiveFeature = dto.DistinctiveFeature, MicrochipOrTattoNumber = dto.MicrochipOrTattoNumber, MicrochipOrTattoApplyDate = dto.MicrochipOrTattoApplyDate, GpsColarId = dto.GpsColarId, Gender = (int)dto.Gender, DocumentFrontImageId = dto.DocumentFrontImage?.Id, ImageId = dto.Image?.Id, BreedId = dto.Breed?.Id, CoatId = dto.Coat?.Id, FurColorId = dto.FurColor?.Id }); }
public DTOResponse <DTOPet> Create(DTOPet createPetInfo) { return(_petDomain.Create(createPetInfo)); }