Exemple #1
0
        public static HwProductPlan Get(int hwShipOrderId, int custProductId)
        {
            ShippmentEntities db  = new ShippmentEntities();
            HwProductPlan     prd = (from p in db.HwProductPlans
                                     where p.CustProductId == custProductId && p.HwShipOrderId == hwShipOrderId
                                     select p).FirstOrDefault();

            return(prd);
        }
Exemple #2
0
        public static bool Exist(HwProductPlan prodPlan)
        {
            ShippmentEntities db = new ShippmentEntities();
            var plans            = (from m in db.HwProductPlans
                                    where m.HwShipOrderId == prodPlan.HwShipOrderId &&
                                    m.CustProduct.Id == prodPlan.CustProduct.Id
                                    select m).ToList();

            return(plans.Count > 0);
        }
Exemple #3
0
        public static ErrorInfo Delete(int id)
        {
            ShippmentEntities db   = new ShippmentEntities();
            HwProductPlan     plan = db.HwProductPlans.FirstOrDefault(p => p.Id == id);

            if (plan != null)
            {
                db.Entry(plan).State = EntityState.Deleted;
                if (db.SaveChanges() > 0)
                {
                    return(ErrorInfo.Succeed);
                }
            }
            return(ErrorInfo.Err_Internal_Error);
        }
Exemple #4
0
        public static ErrorInfo Add(HwProductPlan prodPlan)
        {
            if (Exist(prodPlan))
            {
                return(ErrorInfo.Err_Resource_Exist);
            }
            ShippmentEntities db = new ShippmentEntities();

            db.HwProductPlans.Add(prodPlan);
            if (db.SaveChanges() > 0)
            {
                return(ErrorInfo.Succeed);
            }
            else
            {
                return(ErrorInfo.Err_Internal_Error);
            }
        }
Exemple #5
0
        public static ErrorInfo Edit(int id, HwProductPlan prodPlan)
        {
            if (id != prodPlan.Id)
            {
                return(ErrorInfo.Err_Bad_Request_Information);
            }
            ShippmentEntities db   = new ShippmentEntities();
            HwProductPlan     plan = db.HwProductPlans.FirstOrDefault(p => p.Id == id);

            if (plan != null)
            {
                plan.Qty             = prodPlan.Qty;
                plan.HwShipOrderId   = prodPlan.HwShipOrderId;
                plan.CustProductId   = prodPlan.CustProductId;
                db.Entry(plan).State = EntityState.Modified;
                if (db.SaveChanges() > 0)
                {
                    return(ErrorInfo.Succeed);
                }
            }
            return(ErrorInfo.Err_Internal_Error);
        }