public async Task AddComment(Comment comment)
        {
            comment.Text = await _censorshipService.CensorText(comment.Text);

            try
            {
                await _context.Comments.AddAsync(comment);

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public async Task <int> AddApplication(AddApplication applicationDto)
        {
            Application application;

            try
            {
                Geolocation geolocation = new Geolocation {
                    Latitude = applicationDto.Latitude, Longitude = applicationDto.Longitude
                };
                await _context.Geolocations.AddAsync(geolocation);

                await _context.SaveChangesAsync();

                Adress adress = new Adress {
                    CityId = applicationDto.CityId, Street = applicationDto.Street, GeolocationId = geolocation.GeolocationId
                };
                await _context.Adresses.AddAsync(adress);

                await _context.SaveChangesAsync();

                application          = _mapper.Map <AddApplication, Application>(applicationDto);
                application.AdressId = adress.AdressId;
                application.StatusId = 1;
                application.Title    = await _textControlService.CensorText(application.Title);

                application.Description = await _textControlService.CensorText(application.Description);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            try
            {
                await _context.Applications.AddAsync(application);

                await _context.SaveChangesAsync();

                return(application.ApplicationId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }