Пример #1
0
        public ErrorInfo Edit(int id, CustProduct custProduct)
        {
            if (id != custProduct.Id)
            {
                return(ErrorInfo.Err_Bad_Request_Information);
            }
            ShippmentEntities db  = new ShippmentEntities();
            CustProduct       prd = db.CustProducts.FirstOrDefault(p => p.Id == id && !p.IsDeleted);

            if (prd == null)
            {
                return(ErrorInfo.Err_Resource_NotExist);
            }
            else
            {
                prd.CustCode        = custProduct.CustCode;
                prd.Original        = custProduct.Original;
                prd.CusItemCode     = custProduct.CusItemCode;
                prd.CusVersion      = custProduct.CusVersion;
                prd.CusModelNo      = custProduct.CusModelNo;
                prd.CusDescription  = custProduct.CusDescription;
                prd.IsDeleted       = custProduct.IsDeleted;
                prd.PartNo          = custProduct.PartNo;
                db.Entry(prd).State = EntityState.Modified;
                if (db.SaveChanges() > 0)
                {
                    return(ErrorInfo.Succeed);
                }
                else
                {
                    return(ErrorInfo.Err_Internal_Error);
                }
            }
        }
Пример #2
0
        public static int GetCustproductId(string custCode, string custItemCode)
        {
            ShippmentEntities db  = new ShippmentEntities();
            CustProduct       prd = db.CustProducts.FirstOrDefault(p => p.CustCode == custCode && p.CusItemCode == custItemCode && !p.IsDeleted);

            return(prd.Id);
        }
Пример #3
0
        public ErrorInfo Delete(int id)
        {
            ShippmentEntities db  = new ShippmentEntities();
            CustProduct       prd = db.CustProducts.FirstOrDefault(p => p.Id == id && !p.IsDeleted);

            if (prd == null)
            {
                return(ErrorInfo.Err_Resource_NotExist);
            }
            prd.IsDeleted = true;
            return(Edit(id, prd));
        }
Пример #4
0
        public CustProduct Get(int id)
        {
            if (id == 0)
            {
                return(new CustProduct());
            }
            ShippmentEntities db  = new ShippmentEntities();
            CustProduct       prd = (from p in db.CustProducts
                                     where p.Id == id && !p.IsDeleted
                                     select p).FirstOrDefault();

            return(prd);
        }
Пример #5
0
        public ErrorInfo Add(CustProduct custProduct)
        {
            ShippmentEntities db = new ShippmentEntities();

            db.CustProducts.Add(custProduct);
            if (db.SaveChanges() > 0)
            {
                return(ErrorInfo.Succeed);
            }
            else
            {
                return(ErrorInfo.Err_Internal_Error);
            }
        }