Esempio n. 1
0
        public JsonResult saveOrder(string[] arrayProduct, string Customer, string RFC, string DeliveryDate, string Comments)
        {
            List <string> List = new List <string>();

            try
            {
                using (ABCEntities db = new ABCEntities())
                {
                    ORDERS Order = new ORDERS();
                    Order.ID_Customer = 1;
                    Order.Order_Date  = DateTime.Now;
                    Order.Order_Date  = Convert.ToDateTime(DeliveryDate);
                    Order.Comments    = Comments;
                    Order.Status      = 0;

                    dbContext.ORDERS.Add(Order);
                    dbContext.SaveChanges();
                    var id = Order.ID;


                    return(Json(""));
                }
            }
            catch (WebException ex)
            {
                return(Json(ex.Message.ToString()));
            }
        }
Esempio n. 2
0
 public static ResultObject Add(Model model)
 {
     try
     {
         if (model == null)
         {
             throw new BusinessException(Errors.Codes.ModelNotExist);
         }
         ABCEntities context = new ABCEntities();
         Colors.checkColor(model.ColorId, context);
         Types.checkType(model.TypeId, context);
         if (model.IsConvertible == null)
         {
             model.IsConvertible = 0;
         }
         if (model.IsConvertible > 1)
         {
             model.IsConvertible = 1;
         }
         checkUniqueModel(model.ColorId.Value, model.TypeId.Value, model.IsConvertible.Value, context);
         context.MODEL.Add(new MODEL()
         {
             COLOR_ID    = model.ColorId.Value,
             CONVERTIBLE = model.IsConvertible.Value,
             TYPE_ID     = model.TypeId.Value
         });
         context.SaveChanges();
         return(BasicWrapper.SuccessResult(new object()));
     }
     catch (BusinessException exp)
     {
         return(BasicWrapper.ErrorResult(exp.Code, exp.Message));
     }
     catch (Exception exp)
     {
         return(BasicWrapper.GeneralErrorResult());
     }
 }
        //To Implement
        //Method name: CreateParcel
        //Return Type: Void
        //Parameter type: Parcel
        //Parsmenter Name: New_Parcel_Record
        //Submission: Assignment 2
        //Date: 11-03-2015

        public void CreateParcel(Parcel New_Parcel_Record)
        {
            _dbcontext.Parcel.Add(New_Parcel_Record);
            _dbcontext.SaveChanges();
        }