コード例 #1
0
        public async Task <int> BindToRoasterNdAddressAsync(Guid id)
        {
            try
            {
                _logger.Information("Roaster request service layer access in progress...");

                var request = await _roasterRequestRepository.GetSingleAsync(id);

                var bindTags = await RoasterRequestServiceBuilder.BuildAndBindTags(request.TagString,
                                                                                   _tagRepository);

                var address = Address.New(request.Address.AddressStr,
                                          request.Address.OpeningHours,
                                          request.Address.Latitude,
                                          request.Address.Longitude);

                var roaster = RoasterRequestServiceBuilder.GenerateRoaster(request.Roaster);

                roaster.OfficeAddress = address;

                _addressRepository.Add(address);

                BytePictureBuilder.BindPicture(roaster.Id, request.Picture.Bytes, _pictureRepository);

                _roasterRepository.Add(roaster);

                RoasterTagsPairsBuilder.BuildRoasterTags(bindTags,
                                                         roaster.Id,
                                                         _roasterTagRepository);

                _pictureRequestRepository.Delete(request.Picture);
                _roasterRequestRepository.Delete(request);

                await _roasterRequestRepository.SaveChangesAsync();

                _logger.Information($"Roaster requests table has been modified. Roaster request:\n Id:{request.Id}");
                return(0);
            }
            catch (Exception e)
            {
                _logger.Error($"Roaster request service layer error occured! Error text message: {e.Message}");
                return(-1);
            }
        }
コード例 #2
0
        public async Task <IActionResult> DeleteRoasterRequest(Guid id)
        {
            try
            {
                var roasterReq = await _roasterRequestRepository.GetSingleAsync(id);

                _roasterRequestRepository.Delete(roasterReq);
                await _roasterRequestRepository.SaveChangesAsync();

                return(Ok());
            }
            catch
            {
                return(BadRequest("Unable to delete row! Wrong RoasterRequest format!"));
            }
        }