예제 #1
0
 /// <summary>
 /// insert entry
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="entity"></param>
 public bool Insert <T>(T entity) where T : class
 {
     if (entity == null)
     {
         return(false);
     }
     _context.Entry(entity).State = EntityState.Added;
     //context.Set<T>().Add(entity);
     _context.SaveChanges();
     return(true);
 }
예제 #2
0
 public void UpdateOQCCheck(tbl_test_log production, string operatorCode)
 {
     if (production != null)
     {
         production.QA_Check  = true;
         production.CheckBy   = operatorCode;
         production.DateCheck = DateTime.Now;
         try
         {
             _context.Entry(production).State = EntityState.Modified;
             _context.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new Exception(ex.Message);
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Update Model
        /// </summary>
        /// <param name="modelId"></param>
        /// <param name="createdBy"></param>
        /// <param name="quantity"></param>
        /// <param name="serialNo"></param>
        public void UpdateModel(string modelId, string createdBy, int quantity, string serialNo)
        {
            var model = GetModels().FirstOrDefault(m => m.ModelID == modelId);

            if (model != null)
            {
                model.CreatedBy = createdBy;
                model.Quantity  = quantity;
                model.SerialNo  = serialNo;
                try
                {
                    _context.Models.Attach(model);
                    _context.Entry(model).State = EntityState.Modified;
                    _context.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }