public bool UpdateEquipmentQuantityById(int id, int quantity)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                Equipment equipment = GetEquipmentById(id);
                equipment.Quantity = equipment.Quantity - quantity;

                if (equipment != null)
                {
                    try
                    {
                        db.Equipments.Attach(equipment);
                        db.Entry(equipment).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        return(false);

                        throw;
                    }
                }
                return(true);
            }
        }
Exemplo n.º 2
0
 public bool DeleteCast(string username)
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         try
         {
             Cast cast = db.Casts
                         .Where(x => x.Username == username)
                         .SingleOrDefault();
             if (cast == null)
             {
                 return(false);
             }
             // db.Casts.Remove(cast);
             cast.Role = 3;
             db.Casts.Attach(cast);
             db.Entry(cast).State = EntityState.Modified;
             db.SaveChanges();
             return(true);
         }
         catch (Exception ex)
         {
             return(false);
         }
     }
 }
        public bool UpdateEquipment(Equipment equipment)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                if (equipment != null)
                {
                    try
                    {
                        db.Equipments.Attach(equipment);
                        db.Entry(equipment).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        return(false);

                        throw;
                    }
                }
                return(true);
            }
        }
Exemplo n.º 4
0
        public bool UpdateScene(Scene scene)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                if (scene != null)
                {
                    try
                    {
                        db.Scenes.Attach(scene);
                        db.Entry(scene).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        return(false);

                        throw;
                    }
                }
                return(true);
            }
        }
        public bool UpdateImpersonation(Impersonation impersonation)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                if (impersonation != null)
                {
                    try
                    {
                        db.Impersonations.Attach(impersonation);
                        db.Entry(impersonation).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        return(false);

                        throw;
                    }
                }
                return(true);
            }
        }
        public bool Update(EquipmentUsingHistory rc)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                if (rc != null)
                {
                    try
                    {
                        UpdateQuantityEquipmentForEdit(rc);
                        db.EquipmentUsingHistories.Attach(rc);
                        db.Entry(rc).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        return(false);

                        throw;
                    }
                }
                return(true);
            }
        }