public async Task <PetAlert> Post(PetAlertCreateRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } return(await _petAlertProvider.CreatePetAlertAsync(request) .ConfigureAwait(false)); }
public PetAlert AddPetPublicAlert(PetPublicAlertViewModel model, List <string> urlImages) { var request = new PetAlertCreateRequest { OwnerId = model.OwnerId, Latitude = model.Latitude.Value, Longitude = model.Longitude.Value, Comment = HttpUtility.HtmlEncode(model.Commets), PositionImageUrl = model.StaticMapUrl, Type = model.SelectedAlertTypeId, UrlImages = urlImages }; var response = _findMyPetClient.JsonClient().Post(request); return(response); }
public PetAlert AddPetAlert(PetAlertViewModel model) { var request = new PetAlertCreateRequest { OwnerId = model.OwnerId, PetCode = Guid.Parse(model.PetCode), Latitude = model.Latitude.Value, Longitude = model.Longitude.Value, Comment = HttpUtility.HtmlEncode(model.Commets), PositionImageUrl = model.StaticMapUrl, Type = model.Type }; var response = _findMyPetClient.JsonClient().Post(request); return(response); }
public async Task <PetAlert> CreatePetAlertAsync(PetAlertCreateRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var table = _petAlertMapper.MapCreateRequestToTable(request); int newId = 0; if (request.PetId.HasValue || request.PetCode.HasValue) { PetTableModel pet = null; if (request.PetId.HasValue) { pet = await _petDataAccess.GetPetByIdAsync(request.PetId.Value) .ConfigureAwait(false); } else if (request.PetCode.HasValue) { pet = await _petDataAccess.GetPetByCodeAsync(request.PetCode.Value) .ConfigureAwait(false); } table.PetId = pet.Id; newId = await _petAlertDataAccess.AddPetAlertAsync(table) .ConfigureAwait(false); } else { var alertImages = request.UrlImages.ConvertAll(x => _petAlertMapper.MapImagesToTable(x)); newId = await _petAlertDataAccess.AddPetPublicAlertAsync(table, alertImages) .ConfigureAwait(false); } var newTable = await _petAlertDataAccess.GetPetAlertByIdAsync(newId) .ConfigureAwait(false); return(_petAlertMapper.MapPetAlertTableToPetAlert(newTable)); }
public PetAlertTableModel MapCreateRequestToTable(PetAlertCreateRequest request) { return(new PetAlertTableModel { Code = Guid.NewGuid(), OwnerTableModelId = request.OwnerId, PetId = request.PetId, AlertType = request.Type, Comment = request.Comment, Latitude = request.Latitude, Longitude = request.Longitude, //ImageUrl = request.ImageUrl, PositionImageUrl = request.PositionImageUrl, AlertStatus = (int)AlertStatusEnum.Active, CreatedOn = System.DateTime.Now, MakeItPublic = false, Approved = (int)ApproveStatusEnum.Pending }); }