public bool DeleteShippingMethods(long shipping_method_id) { try { shipping_method oShippingMethods = _entities.shipping_method.FirstOrDefault(st => st.shipping_method_id == shipping_method_id); oShippingMethods.is_deleted = true; _entities.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public bool UpdateShippingMethods(shipping_method oShippingMethods) { try { shipping_method con = _entities.shipping_method.Find(oShippingMethods.shipping_method_id); con.shipping_method_name = oShippingMethods.shipping_method_name; con.updated_date = DateTime.Now; con.is_active = oShippingMethods.is_active; _entities.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public bool InsertShippingMethods(shipping_method oShippingMethods) { try { shipping_method insertShippingMethods = new shipping_method { shipping_method_name = oShippingMethods.shipping_method_name, created_by = oShippingMethods.created_by, created_date = oShippingMethods.created_date, updated_by = oShippingMethods.updated_by, updated_date = oShippingMethods.updated_date, is_active = oShippingMethods.is_active, is_deleted = oShippingMethods.is_deleted }; _entities.shipping_method.Add(insertShippingMethods); _entities.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public void Run() { var orderApiClient = new OrderAPISoapClient(); var cred = new Credentials(); cred.Username = Properties.Settings.Default.ByDesignApiUser; cred.Password = Properties.Settings.Default.ByDesignApiPassword; var responseShippingMethods = orderApiClient.GetShippingMethods(cred); using (var dbContext = new BiWellEntities()) { dbContext.Database.Log = s => Debug.WriteLine(s); foreach (var sm in responseShippingMethods) { var dbShippingMethod = dbContext.shipping_method.Find(sm.ID); if (dbShippingMethod != null) { dbShippingMethod.description = sm.Description; } else { dbShippingMethod = new shipping_method { id = sm.ID, description = sm.Description }; dbContext.shipping_method.Add(dbShippingMethod); } } dbContext.SaveChanges(); } }