Ejemplo n.º 1
0
        public async Task <IHttpActionResult> Send(int?id)
        {
            try
            {
                Package package = Db.Packages.FirstOrDefault(p => p.Id == id);

                Validator validator = PackageValidator.Send(package);
                if (!validator.Success)
                {
                    return(BadRequest(validator.ErrorMessage));
                }

                package.Status = Status.InTransit;
                await Db.SaveChangesAsync();

                return(Ok("Package was sent"));
            }
            catch
            {
                return(BadRequest("An error has occurred"));
            }
        }