public User Create(User oUser) { try { using (var ctx = new DBAJEntities()) { oUser.UserId = Guid.NewGuid(); ctx.Users.Add(oUser); ctx.SaveChanges(); return(oUser); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } catch (Exception ex) { throw ex; } }
public bool MoveShades(ShadeCard oSelectedShade, ShadeCard oAffectedShade) { try { using (var ctx = new DBAJEntities()) { int?SelectedOrderId = oSelectedShade.DisplayOrder; int?affectOrderId = oAffectedShade.DisplayOrder; //selected shade oSelectedShade.DisplayOrder = affectOrderId; ctx.Entry(oSelectedShade).State = EntityState.Modified; //affected shade oAffectedShade.DisplayOrder = SelectedOrderId; ctx.Entry(oAffectedShade).State = EntityState.Modified; ctx.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public void Update(User oUser) { try { using (var ctx = new DBAJEntities()) { ctx.Entry(oUser).State = EntityState.Modified; ctx.SaveChanges(); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } catch (Exception ex) { throw ex; } }
public void Create(FinanceSale oFinanceSale) { try { using (var ctx = new DBAJEntities()) { ctx.FinanceSales.Add(oFinanceSale); ctx.SaveChanges(); } } catch (Exception) { throw; } }
public void Update(SiteConfig oSiteConfig) { try { using (var ctx = new DBAJEntities()) { ctx.Entry(oSiteConfig).State = EntityState.Modified; ctx.SaveChanges(); } } catch (Exception) { throw; } }
public void ChangePassword(string password, User oUser) { try { using (var ctx = new DBAJEntities()) { ctx.Database.ExecuteSqlCommand("update Users set password='******' where UserId='" + oUser.UserId + "'"); ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Update(EmbroideryFirmPriceSetting oEmbroideryFirmPriceSetting) { try { using (var ctx = new DBAJEntities()) { ctx.Entry(oEmbroideryFirmPriceSetting).State = EntityState.Modified; ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Create(SiteConfig oSiteConfig) { try { using (var ctx = new DBAJEntities()) { ctx.SiteConfigs.Add(oSiteConfig); ctx.SaveChanges(); } } catch (Exception) { throw; } }
public void Update(JariCompany oJariCompany) { try { using (var ctx = new DBAJEntities()) { ctx.Entry(oJariCompany).State = EntityState.Modified; ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Create(EmbroideryFirmPriceSetting oEmbroideryFirmPriceSetting) { try { using (var ctx = new DBAJEntities()) { ctx.EmbroideryFirmPriceSettings.Add(oEmbroideryFirmPriceSetting); ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Update(FinanceSale oFinanceSale) { try { using (var ctx = new DBAJEntities()) { ctx.Entry(oFinanceSale).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } } catch (Exception) { throw; } }
public bool Delete(int id) { try { using (var ctx = new DBAJEntities()) { EmbroideryFirmPriceSetting oEmbroideryFirmPriceSetting = ctx.EmbroideryFirmPriceSettings.Where(p => p.EmbroideryFirmPriceSettingsId == id).FirstOrDefault(); ctx.EmbroideryFirmPriceSettings.Remove(oEmbroideryFirmPriceSetting); ctx.SaveChanges(); return(true); } } catch (Exception ex) { return(false); } }
public bool Delete(Guid id) { try { using (var ctx = new DBAJEntities()) { EmbroideryFirmLocation oEmbroideryFirmLocation = ctx.EmbroideryFirmLocations.Where(p => p.EmbroideryFirmLocationId == id).FirstOrDefault(); ctx.EmbroideryFirmLocations.Remove(oEmbroideryFirmLocation); ctx.SaveChanges(); return(true); } } catch (Exception ex) { return(false); } }
public void Create(JariCompany oJariCompany) { try { using (var ctx = new DBAJEntities()) { oJariCompany.CreateDate = DateTime.UtcNow; ctx.JariCompanies.Add(oJariCompany); ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public bool Delete(int id) { try { using (var ctx = new DBAJEntities()) { JariCompany oJariCompany = ctx.JariCompanies.Where(p => p.JariCompanyId == id).FirstOrDefault(); ctx.JariCompanies.Remove(oJariCompany); ctx.SaveChanges(); return(true); } } catch (Exception ex) { return(false); } }
public bool Delete(int id) { try { using (var ctx = new DBAJEntities()) { ShadeCard oShadeCard = ctx.ShadeCards.Where(p => p.ShadeId == id).FirstOrDefault(); ctx.ShadeCards.Remove(oShadeCard); ctx.SaveChanges(); return(true); } } catch (Exception ex) { return(false); } }
public void SetDefaultPrimaryLocation(EmbroideryFirmLocation oEmbroideryFirmLocation) { try { if (oEmbroideryFirmLocation.IsPrimaryLocation == true) { ResetPrimaryLocation(oEmbroideryFirmLocation.EmbroideryFirmId); } using (var ctx = new DBAJEntities()) { ctx.Entry(oEmbroideryFirmLocation).State = EntityState.Modified; ctx.SaveChanges(); } } catch (Exception) { throw; } }
public void ResetPrimaryLocation(Guid EmbroideryFirmId) { try { using (var ctx = new DBAJEntities()) { List <EmbroideryFirmLocation> lstLocations = ctx.EmbroideryFirmLocations.Where(t => t.IsPrimaryLocation == true && t.EmbroideryFirmId == EmbroideryFirmId).ToList(); if (lstLocations.Count > 0 && lstLocations != null) { lstLocations.ForEach(a => a.IsPrimaryLocation = false); ctx.SaveChanges(); } } } catch (Exception ex) { throw ex; } }
public void Create(EmbroideryFirmLocation oEmbroideryFirmLocation) { try { if (oEmbroideryFirmLocation.IsPrimaryLocation == true) { ResetPrimaryLocation(oEmbroideryFirmLocation.EmbroideryFirmId); } using (var ctx = new DBAJEntities()) { ctx.EmbroideryFirmLocations.Add(oEmbroideryFirmLocation); ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Update(ShadeCard oShadeCard) { try { using (var ctx = new DBAJEntities()) { if (oShadeCard.DisplayOrder == null) { oShadeCard.DisplayOrder = (ctx.ShadeCards.OrderByDescending(c => c.ShadeId).FirstOrDefault().ShadeId) + 1; } ctx.Entry(oShadeCard).State = EntityState.Modified; ctx.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public bool Delete(Guid id) { using (var ctx = new DBAJEntities()) { using (var dbContextTransaction = ctx.Database.BeginTransaction()) { try { User oUser = ctx.Users.Where(p => p.UserId == id).FirstOrDefault(); ctx.Users.Remove(oUser); ctx.SaveChanges(); dbContextTransaction.Commit(); return(true); } catch (Exception ex) { dbContextTransaction.Rollback(); return(false); } } } }