public async Task <IResult> UpdateAsync(long locationId, UpdateLocationModel updateLocationModel) { var validation = new LocationModelValidator().Valid(updateLocationModel); if (!validation.Success) { return(new ErrorDataResult <long>(validation.Message)); } var locationEntity = await LocationRepository.SelectAsync(locationId); var nullObjectValidation = new NullObjectValidation <LocationEntity>().Valid(locationEntity); if (!nullObjectValidation.Success) { return(new ErrorResult(nullObjectValidation.Message)); } var locationDomain = LocationDomainFactory.Create(locationEntity); locationDomain.Update(updateLocationModel); locationEntity = locationDomain.Map <LocationEntity>(); locationEntity.LocationId = locationId; await LocationRepository.UpdateAsync(locationEntity, locationEntity.LocationId); await DatabaseUnitOfWork.SaveChangesAsync(); return(new SuccessResult()); }
public async Task <IDataResult <long> > AddAsync(AddLocationModel addLocationModel) { var validation = new LocationModelValidator().Valid(addLocationModel); if (!validation.Success) { return(new ErrorDataResult <long>(validation.Message)); } var locationDomain = LocationDomainFactory.Create(addLocationModel); locationDomain.Add(); var locationEntity = locationDomain.Map <LocationEntity>(); await LocationRepository.AddAsync(locationEntity); await DatabaseUnitOfWork.SaveChangesAsync(); return(new SuccessDataResult <long>(locationEntity.LocationId)); }