Beispiel #1
0
        public static bool UpdateCustomerRepair(string connectionString, CustomerRepair customerRepair)
        {
            try
            {
                _connectionString = connectionString;

                var entry = DBContextInstance.Entry(customerRepair);
                entry.State = EntityState.Modified;
                var result = DBContextInstance.SaveChanges();
                return(result > 0);
            }
            catch (Exception exception)
            {
                NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured, ExceptionResources.ExceptionOccuredLogDetail);
                return(false);
            }
        }
Beispiel #2
0
        public static bool AddCustomerRepair(string connectionString, CustomerRepair customerRepair)
        {
            try
            {
                using (var context = new CustomerDBContext(connectionString))
                {
                    var cloneObject = customerRepair.CreateAClone();
                    cloneObject.ApplyCurrentDateTime();
                    context.CustomerRepairs.Add(cloneObject);

                    var result = context.SaveChanges();
                    return(result > 0);
                }
            }
            catch (Exception exception)
            {
                NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured,
                                    ExceptionResources.ExceptionOccuredLogDetail);
                return(false);
            }
            return(false);
        }
Beispiel #3
0
 public static bool DeleteCustomerRepair(string connectionString, CustomerRepair customerRepair)
 {
     try
     {
         //using (var context = new CustomerDBContext(connectionString))
         {
             _connectionString = connectionString;
             DBContextInstance.CustomerRepairs.Attach(new CustomerRepair()
             {
                 ID = customerRepair.ID
             });
             DBContextInstance.CustomerRepairs.Remove(customerRepair);
             var result = DBContextInstance.SaveChanges();
             return(result > 0);
         }
     }
     catch (Exception exception)
     {
         NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured,
                             ExceptionResources.ExceptionOccuredLogDetail);
         return(false);
     }
 }