Exemple #1
0
        public IHttpActionResult AddPackageToLine(int lineId, Package package)
        {
            if (lineId < 1)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NoContent, "Sorry,Line id Can not be smaller than 1")));
            }

            if (package == null)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NoContent, "Sorry, we could not get the data")));
            }

            Package addedPackage;

            try
            {
                addedPackage = _packageManager.AddPackageToLine(lineId, package);
            }
            catch (Exception)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Something went wrong")));
            }

            if (addedPackage != null)
            {
                return(Ok(addedPackage));
            }
            else
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Sorry, we could not add the package")));
            }
        }