/// <summary> /// Create an object Car from a LegacyCarVM /// </summary> /// <param name="legacy">Object LegacyCarVM</param> /// <returns>Returns a object Car</returns> public static Car Create(LegacyCarVM legacy) { if (legacy == null) { throw new ArgumentNullException(nameof(legacy)); } return(new Car { Id = Guid.NewGuid(), IdLegacy = legacy.Id, Description = legacy.Description }); }
/// <summary> /// Save a record using a worker /// </summary> /// <param name="viewModel"></param> /// <returns></returns> public async Task <DomainResponse> SaveWorker(LegacyCarVM viewModel) { var car = CarFactory.Create(viewModel); Telemetry.TrackEvent("Save Record"); var query = Repository.GetAsync <Car>(x => x.Id.ToString() == viewModel.Id).Result; var carReturn = query.AsEnumerable().FirstOrDefault(); if (carReturn != null) { car.Id = carReturn.Id; } var records = await Repository.AddOrUpdateAsync(car); return(Response(records)); }