Exemplo n.º 1
0
        public MethodResult <CreateSalesOrderResultCodeEnum, SalesOrderHeader> CreateSalesOrder(SalesOrderHeader order)
        {
            if (order.DueDate.Day == 3)
            {
                return(MethodResult <CreateSalesOrderResultCodeEnum, SalesOrderHeader> .CreateError(CreateSalesOrderResultCodeEnum.OUT_OF_STOCK, "[[[OUT_OF_STOCK]]]"));
            }
            ;

            this.AdventureWorksDb.SalesOrderHeaders.Add(order);
            try
            {
                this.AdventureWorksDb.SaveChanges();
                return(MethodResult <CreateSalesOrderResultCodeEnum, SalesOrderHeader> .CreateSuccess(CreateSalesOrderResultCodeEnum.SUCCESS, order));
            }
            catch (Exception ex)
            {
                throw new Exception("Can't Save SalesOrder", ex);
            }
        }