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
                }
            }));
        }
Esempio n. 2
0
 public IResult UpdateLocation(IUpdateLocationParameters parameters)
 {
     try
     {
         return(_facilityServiceProvider.UpdateLocation(parameters));
     }
     catch (Exception ex)
     {
         _exceptionLogger.LogException(ex);
         return(new FailureResult(ex.GetInnermostException().Message));
     }
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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)
            }));
        }