public IResult UpdateLocation(IUpdateLocationParameters parameters) { var parameterResult = parameters.ToParsedParameters(); if (!parameterResult.Success) { return(parameterResult); } var employeeResult = new GetEmployeeCommand(_facilityUnitOfWork).GetEmployee(parameters); if (!employeeResult.Success) { return(employeeResult.ConvertTo <string>()); } var result = new UpdateLocationCommand(_facilityUnitOfWork).UpdateLocation(parameterResult.ResultingObject); if (!result.Success) { return(result); } _facilityUnitOfWork.Commit(); return(SyncParameters.Using(new SuccessResult(), new SyncLocationsParameters { EmployeeKey = employeeResult.ResultingObject, Locations = new List <ILocationKey> { parameterResult.ResultingObject.LocationKey } })); }
public IResult UpdateLocation(IUpdateLocationParameters parameters) { try { return(_facilityServiceProvider.UpdateLocation(parameters)); } catch (Exception ex) { _exceptionLogger.LogException(ex); return(new FailureResult(ex.GetInnermostException().Message)); } }
internal static void AssertEqual(this Location location, IUpdateLocationParameters parameters) { if (location == null) { throw new ArgumentNullException("location"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } Assert.AreEqual(parameters.Description, location.Description); Assert.AreEqual(parameters.Active, location.Active); Assert.AreEqual(parameters.Locked, location.Locked); }
internal static IResult <UpdateLocationParameters> ToParsedParameters(this IUpdateLocationParameters parameters) { var locationKey = KeyParserHelper.ParseResult <ILocationKey>(parameters.LocationKey); if (!locationKey.Success) { return(locationKey.ConvertTo <UpdateLocationParameters>(null)); } return(new SuccessResult <UpdateLocationParameters>(new UpdateLocationParameters { Params = parameters, LocationKey = new LocationKey(locationKey.ResultingObject) })); }