public List <Impersonation> GetAllImpersonation()
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.Impersonations.Include(x => x.Cast).ToList());
     }
 }
Exemplo n.º 2
0
 public bool CheckSceneRecordedOrNot(int?sceneId)
 {
     using (var entity = new JOURNEYTOTHEWESTEntities())
     {
         return(entity.Scenes.Where(x => x.EndTime >= DateTime.Now && x.Id == sceneId).FirstOrDefault() == null ? true : 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 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 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);
                }
            }
        }
Exemplo n.º 8
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);
                }
            }
        }
        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);
                }
            }
        }
Exemplo n.º 11
0
        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 List <RecordHistory> GetAll()
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.RecordHistories.Select(x => x)
                .ToList());
     }
 }
Exemplo n.º 13
0
 public List <Scene> GetAllScene()
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.Scenes.Select(x => x)
                .ToList());
     }
 }
Exemplo n.º 14
0
 public bool isAvailbleQuantity(int id, int quantity)
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.Equipments
                .Where(x => x.Id == id && x.Quantity >= quantity).SingleOrDefault() != null ? true :false);
     }
 }
Exemplo n.º 15
0
 public List <Equipment> GetAllEquipment()
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.Equipments.Select(x => x)
                .ToList());
     }
 }
Exemplo n.º 16
0
 public List <Cast> GetAllCast()
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.Casts.Where(x => x.Role != 3).Select(x => x)
                .ToList());
     }
 }
Exemplo n.º 17
0
 public List <Scene> GetSceneByName(string name)
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.Scenes
                .Where(x => x.Name.Contains(name))
                .ToList());
     }
 }
Exemplo n.º 18
0
 public Scene GetSceneById(int id)
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.Scenes
                .Where(x => x.Id == id)
                .SingleOrDefault());
     }
 }
Exemplo n.º 19
0
 public Cast GetCastById(string username)
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.Casts
                .Where(x => x.Username == username)
                .SingleOrDefault());
     }
 }
Exemplo n.º 20
0
 public Admin GetAdminById(string username)
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.Admins
                .Where(x => x.Username == username)
                .SingleOrDefault());
     }
 }
 public List <Impersonation> GetImpersonationByName(string name)
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.Impersonations
                .Where(x => x.Name.Contains(name))
                .ToList());
     }
 }
Exemplo n.º 22
0
 public Equipment GetEquipmentById(int id)
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.Equipments
                .Where(x => x.Id == id)
                .SingleOrDefault());
     }
 }
Exemplo n.º 23
0
 public List <Equipment> GetEquipmentByName(string name)
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.Equipments
                .Where(x => x.Name.Contains(name))
                .ToList());
     }
 }
Exemplo n.º 24
0
 public List <Equipment> GetAvailbleEquipmentById(int id)
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.Equipments
                .Where(x => x.Id == id && x.Quantity > 0)
                .ToList());
     }
 }
Exemplo n.º 25
0
 public List <Cast> GetCastByName(string name)
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.Casts
                .Where(x => x.FullName.Contains(name))
                .ToList());
     }
 }
Exemplo n.º 26
0
 public Admin CheckLogin(string username, string password)
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.Admins
                .Where(x => x.Username == username && x.Password == password)
                .SingleOrDefault());
     }
 }
 public Impersonation GetImpersonationById(int id)
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.Impersonations
                .Where(x => x.Id == id)
                .SingleOrDefault());
     }
 }
 public EquipmentUsingHistory GetEquipment(int sceneId, int eId)
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.EquipmentUsingHistories
                .Where(x => x.SceneId == sceneId && x.EquipmentId == eId)
                .Include(x => x.Scene)
                .Include(x => x.Equipment).SingleOrDefault());
     }
 }
Exemplo n.º 29
0
        public List <Scene> GetSceneByDate(DateTime date, DateTime dateTo)
        {
            //  DateTime tomorrow = date.AddDays(1);

            using (var entity = new JOURNEYTOTHEWESTEntities())
            {
                return(entity.Scenes.Where(x => x.StartTime <= date)
                       .Where(x => x.EndTime >= dateTo).ToList());
            }
        }
 public List <EquipmentUsingHistory> GetEquipmentBySceneId(int sceneId)
 {
     using (var db = new JOURNEYTOTHEWESTEntities())
     {
         return(db.EquipmentUsingHistories
                .Where(x => x.SceneId == sceneId)
                .Include(x => x.Scene)
                .Include(x => x.Equipment).ToList());
     }
 }