Exemplo n.º 1
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 DeleteEquiptment(int id)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                try
                {
                    new EquipmentUsingHistoryDAO().DeleteByEquipmentId(id);
                    var equipment = db.Equipments
                                    .Where(x => x.Id == id)
                                    .SingleOrDefault();

                    if (equipment == null)
                    {
                        return(false);
                    }

                    db.Equipments.Remove(equipment);
                    db.SaveChanges();

                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
Exemplo n.º 3
0
        public bool DeleteScene(int id)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                try
                {
                    new RecordHistoryDAO().DeleteBySceneId(id);
                    new EquipmentUsingHistoryDAO().DeleteBySceneId(id);
                    var scene = db.Scenes
                                .Where(x => x.Id == id)
                                .SingleOrDefault();
                    if (scene == null)
                    {
                        return(false);
                    }

                    db.Scenes.Remove(scene);
                    db.SaveChanges();

                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
        public bool Delete(int sceneId, int equipmentId)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                try
                {
                    var rc = db.EquipmentUsingHistories
                             .Where(x => x.SceneId == sceneId && x.EquipmentId == equipmentId)
                             .SingleOrDefault();

                    if (rc == null)
                    {
                        return(false);
                    }

                    UpdateQuantityEquipment(rc, true);

                    db.EquipmentUsingHistories.Remove(rc);
                    db.SaveChanges();

                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
        public bool DeleteByEquipmentId(int eId)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                try
                {
                    List <EquipmentUsingHistory> rc = db.EquipmentUsingHistories
                                                      .Where(x => x.EquipmentId == eId)
                                                      .ToList();

                    if (rc == null)
                    {
                        return(false);
                    }

                    foreach (EquipmentUsingHistory r in rc)
                    {
                        UpdateQuantityEquipment(r, true);
                        db.EquipmentUsingHistories.Remove(r);
                        db.SaveChanges();
                    }

                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
        public bool DeleteByImperId(int id)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                try
                {
                    List <RecordHistory> list = db.RecordHistories
                                                .Where(x => x.ImpersonationId == id)
                                                .ToList();

                    if (list == null)
                    {
                        return(false);
                    }

                    foreach (RecordHistory rc in list)
                    {
                        db.RecordHistories.Remove(rc);
                        db.SaveChanges();
                    }

                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
        public bool Delete(int id)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                try
                {
                    var rc = db.RecordHistories
                             .Where(x => x.Id == id)
                             .SingleOrDefault();

                    if (rc == null)
                    {
                        return(false);
                    }

                    db.RecordHistories.Remove(rc);
                    db.SaveChanges();

                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
        public bool DeleteImpersonation(int id)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                try
                {
                    new RecordHistoryDAO().DeleteByImperId(id);
                    var impersonation = db.Impersonations
                                        .Where(x => x.Id == id)
                                        .SingleOrDefault();

                    if (impersonation == null)
                    {
                        return(false);
                    }

                    db.Impersonations.Remove(impersonation);
                    db.SaveChanges();

                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
        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);
            }
        }
 public bool AddNew(RecordHistory rc)
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         try
         {
             db.RecordHistories.Add(rc);
             db.SaveChanges();
             return(true);
         }
         catch (Exception ex)
         {
             // return false;
             throw;
         }
         return(false);
     }
 }
        public bool AddNewImpersonation(Impersonation impersonation)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                try
                {
                    db.Impersonations.Add(impersonation);
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);

                    throw;
                }
            }
        }
Exemplo n.º 12
0
        public bool AddNewCast(Cast cast)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                try
                {
                    db.Casts.Add(cast);
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);

                    throw;
                }
            }
        }
Exemplo n.º 13
0
        public bool AddNewScene(Scene scene)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                try
                {
                    db.Scenes.Add(scene);
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);

                    throw;
                }
            }
        }
Exemplo n.º 14
0
        public bool AddNewEquipment(Equipment equipment)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                try
                {
                    db.Equipments.Add(equipment);
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);

                    throw;
                }
            }
        }
        public bool AddNew(EquipmentUsingHistory rc)
        {
            using (var db = new JOURNEYTOTHEWESTEntities())
            {
                try
                {
                    UpdateQuantityEquipment(rc, false);
                    db.EquipmentUsingHistories.Add(rc);
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);

                    throw;
                }
            }
        }
Exemplo n.º 16
0
        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.º 17
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);
            }
        }