Beispiel #1
0
        public async Task <IHttpActionResult> AttemptDeliver(int?id)
        {
            try
            {
                Package   package   = Db.Packages.FirstOrDefault(p => p.Id == id);
                Validator validator = PackageValidator.AttemptDeliver(package);
                if (!validator.Success)
                {
                    return(BadRequest(validator.ErrorMessage));
                }

                package.Status = Status.AttemptedDelivery;

                await Db.SaveChangesAsync();

                return(Ok("Attempting delivery"));
            }
            catch
            {
                return(BadRequest("An error has occurred"));
            }
        }