コード例 #1
0
ファイル: CarsController.cs プロジェクト: tranthong90/CarShop
        public HttpResponseMessage Delete(int id)
        {
            string Username;
            bool   IsDealer;

            if (IsAdminOrDealer(out Username, out IsDealer))
            {
                if (id > 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, _carServices.DeleteCarByDealer(id, Username)));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "Id must be greater than 0"));
                }
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Only Admin and Dealer can perform this action"));
            }
        }