Exemplo n.º 1
0
 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;
     }
 }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
 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;
     }
 }
Exemplo n.º 4
0
 public void Create(FinanceSale oFinanceSale)
 {
     try
     {
         using (var ctx = new DBAJEntities())
         {
             ctx.FinanceSales.Add(oFinanceSale);
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 5
0
 public void Update(SiteConfig oSiteConfig)
 {
     try
     {
         using (var ctx = new DBAJEntities())
         {
             ctx.Entry(oSiteConfig).State = EntityState.Modified;
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 6
0
 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;
     }
 }
Exemplo n.º 7
0
 public void Update(EmbroideryFirmPriceSetting oEmbroideryFirmPriceSetting)
 {
     try
     {
         using (var ctx = new DBAJEntities())
         {
             ctx.Entry(oEmbroideryFirmPriceSetting).State = EntityState.Modified;
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 8
0
 public void Create(SiteConfig oSiteConfig)
 {
     try
     {
         using (var ctx = new DBAJEntities())
         {
             ctx.SiteConfigs.Add(oSiteConfig);
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 9
0
 public void Update(JariCompany oJariCompany)
 {
     try
     {
         using (var ctx = new DBAJEntities())
         {
             ctx.Entry(oJariCompany).State = EntityState.Modified;
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 10
0
 public void Create(EmbroideryFirmPriceSetting oEmbroideryFirmPriceSetting)
 {
     try
     {
         using (var ctx = new DBAJEntities())
         {
             ctx.EmbroideryFirmPriceSettings.Add(oEmbroideryFirmPriceSetting);
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 11
0
 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;
     }
 }
Exemplo n.º 12
0
 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);
     }
 }
Exemplo n.º 13
0
 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);
     }
 }
Exemplo n.º 14
0
        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;
            }
        }
Exemplo n.º 15
0
 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);
     }
 }
Exemplo n.º 16
0
 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);
     }
 }
Exemplo n.º 17
0
 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;
     }
 }
Exemplo n.º 18
0
 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;
     }
 }
Exemplo n.º 19
0
 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;
     }
 }
Exemplo n.º 20
0
        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;
            }
        }
Exemplo n.º 21
0
 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);
             }
         }
     }
 }