Ejemplo n.º 1
0
 public static AccountView Login(string email, string password)
 {
     try
     {
         db = new AceEntities();
         string  passHash = MD5_Sang.Encrypt(password);
         Account acc      = db.Account.SingleOrDefault(s => s.Email.Equals(email) && s.Password.Equals(passHash));
         if (acc != null)
         {
             return(new AccountView
             {
                 Id = acc.Id,
                 Email = acc.Email,
                 Address = acc.Address,
                 Name = acc.Name,
                 Password = acc.Password,
                 Phone = acc.Phone,
                 Role = (int)acc.Roles
             });
         }
         return(null);
     }
     catch (Exception e)
     {
         return(null);
     }
 }
Ejemplo n.º 2
0
 public static int Create(List <OrderDetailsView> list)
 {
     try
     {
         db = new AceEntities();
         List <OrderDetails> listDT = new List <OrderDetails>();
         foreach (OrderDetailsView item in list)
         {
             listDT.Add(new OrderDetails
             {
                 Date       = item.Date,
                 OrderId    = item.OrdID,
                 Price      = item.Price,
                 Quantity   = item.Quantity,
                 ServicesId = item.SvID
             });
         }
         db.OrderDetails.AddRange(listDT);
         db.SaveChanges();
         return(list[0].OrdID);
     }
     catch
     {
         return(-1);
     }
 }
Ejemplo n.º 3
0
 public static List <ServicesView> Get()
 {
     db = new AceEntities();
     return(db.Services.AsNoTracking().Select(s => new ServicesView
     {
         Id = s.Id,
         Name = s.Name,
         Price = (decimal)s.Price
     }).ToList());
 }
Ejemplo n.º 4
0
 public static ServicesView GetByID(int id)
 {
     db = new AceEntities();
     return(db.Services.AsNoTracking().Where(s => s.Id == id).Select(s => new ServicesView
     {
         Id = s.Id,
         Name = s.Name,
         Price = (decimal)s.Price
     }).SingleOrDefault());
 }
Ejemplo n.º 5
0
 public static RoomView GetByID(int id)
 {
     db = new AceEntities();
     return(db.Room.AsNoTracking().Where(s => s.Id == id).Select(s => new RoomView
     {
         EmpID = (int)s.IdEmp,
         EmpName = s.IdEmpNavigation.Name,
         Name = s.Name + "",
         Id = s.Id,
         Price = (decimal)s.Price
     }).SingleOrDefault());
 }
Ejemplo n.º 6
0
 public static List <RoomView> Get()
 {
     db = new AceEntities();
     return(db.Room.AsNoTracking().Select(s => new RoomView
     {
         EmpID = (int)s.IdEmp,
         EmpName = s.IdEmpNavigation.Name,
         Name = s.Name + "",
         Id = s.Id,
         Price = (decimal)s.Price
     }).ToList());
 }
Ejemplo n.º 7
0
 public static List <OrderDetailsView> Get(int id)
 {
     db = new AceEntities();
     return(db.OrderDetails.AsNoTracking().Where(s => s.OrderId == id).Select(s => new OrderDetailsView
     {
         OrdID = id,
         Date = (DateTime)s.Date,
         Price = (decimal)s.Price,
         Quantity = (int)s.Quantity,
         SvID = s.ServicesId,
         SvName = s.Services.Name
     }).ToList());
 }
Ejemplo n.º 8
0
 public static List <AccountView> Get()
 {
     db = new AceEntities();
     return(db.Account.AsNoTracking().Select(s => new AccountView
     {
         Id = s.Id,
         Email = s.Email,
         Address = s.Address,
         Name = s.Name,
         Password = s.Password,
         Phone = s.Phone
     }).ToList());
 }
Ejemplo n.º 9
0
 public static bool Remove(int id)
 {
     try
     {
         db = new AceEntities();
         db.Account.Remove(db.Account.Find(id));
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 10
0
 public static AccountView GetByID(int id)
 {
     db = new AceEntities();
     return(db.Account.AsNoTracking().Where(s => s.Id == id).Select(s => new AccountView
     {
         Id = s.Id,
         Email = s.Email,
         Address = s.Address,
         Name = s.Name,
         Password = s.Password,
         Phone = s.Phone,
         Role = (int)s.Roles
     }).SingleOrDefault());
 }
Ejemplo n.º 11
0
 public static List <BookingView> Get()
 {
     db = new AceEntities();
     return(db.Booking.AsNoTracking().Select(s => new BookingView
     {
         CusID = (int)s.IdCustomer,
         CusName = s.IdCustomerNavigation.Name,
         DateEnd = (DateTime)s.DateEnd,
         DateStart = (DateTime)s.DateStart,
         Id = s.Id,
         RoomID = (int)s.RoomId,
         RoomName = s.Room.Name + "",
         Status = s.Status
     }).ToList());
 }
Ejemplo n.º 12
0
 public static BookingView GetByID(int id)
 {
     db = new AceEntities();
     return(db.Booking.AsNoTracking().Where(s => s.Id == id).Select(s => new BookingView
     {
         CusID = (int)s.IdCustomer,
         CusName = s.IdCustomerNavigation.Name,
         DateEnd = (DateTime)s.DateEnd,
         DateStart = (DateTime)s.DateStart,
         Id = s.Id,
         RoomID = (int)s.RoomId,
         RoomName = s.Room.Name + "",
         Status = s.Status
     }).SingleOrDefault());
 }
Ejemplo n.º 13
0
        public static List <RoomView> SearchRoom(DateTime start, DateTime end)
        {
            db = new AceEntities();
            var list = db.Room.Where(s => s.Booking.Count(b =>
                                                          (start >= b.DateStart && (start <= b.DateEnd || end <= b.DateEnd)) || (start <= b.DateStart && end >= b.DateStart)) == 0
                                     ).Select(s => new RoomView
            {
                EmpID   = (int)s.IdEmp,
                EmpName = s.IdEmpNavigation.Name,
                Name    = s.Name.ToString(),
                Id      = s.Id,
                Price   = (decimal)s.Price
            }).ToList();

            return(list);
        }
Ejemplo n.º 14
0
        public static int Create(AccountView acc)
        {
            db = new AceEntities();
            Account account = new Account
            {
                Name     = acc.Name,
                Email    = acc.Email,
                Address  = acc.Address,
                Password = acc.Password,
                Phone    = acc.Phone,
                Roles    = acc.Role
            };

            db.Account.Add(account);
            db.SaveChanges();
            return(account.Id);
        }
Ejemplo n.º 15
0
 public static OrderView GetByID(int id)
 {
     db = new AceEntities();
     return(db.Orders.AsNoTracking().Where(s => s.Id == id).Select(s => new OrderView
     {
         CusID = (int)s.IdCus,
         CusName = s.IdCusNavigation.Name,
         Date = (DateTime)s.Date,
         DateEnd = (DateTime)s.DateEnd,
         DateStart = (DateTime)s.DateStart,
         EmpID = (int)s.IdEmp,
         EmpName = s.IdEmpNavigation.Name,
         RoomID = (int)s.IdRoom,
         RoomName = s.IdRoomNavigation.Name + "",
         Total = (int)s.Total,
         Id = s.Id
     }).SingleOrDefault());
 }
Ejemplo n.º 16
0
 public static List <OrderView> Get()
 {
     db = new AceEntities();
     return(db.Orders.AsNoTracking().Select(s => new OrderView
     {
         CusID = (int)s.IdCus,
         CusName = s.IdCusNavigation.Name,
         Date = (DateTime)s.Date,
         DateEnd = (DateTime)s.DateEnd,
         DateStart = (DateTime)s.DateStart,
         EmpID = (int)s.IdEmp,
         EmpName = s.IdEmpNavigation.Name,
         RoomID = (int)s.IdRoom,
         RoomName = s.IdRoomNavigation.Name + "",
         Total = (int)s.Total,
         Id = s.Id
     }).ToList());
 }
Ejemplo n.º 17
0
 public static int Create(RoomView r)
 {
     try
     {
         db = new AceEntities();
         Room room = new Room
         {
             IdEmp = r.EmpID,
             Name  = Convert.ToInt32(r.Name.Trim()),
             Price = r.Price,
         };
         db.SaveChanges();
         return(room.Id);
     }
     catch
     {
         return(-1);
     }
 }
Ejemplo n.º 18
0
 public static int Create(ServicesView s)
 {
     try
     {
         db = new AceEntities();
         Services services = new Services
         {
             Name  = s.Name,
             Price = s.Price
         };
         db.Services.Add(services);
         db.SaveChanges();
         return(services.Id);
     }
     catch
     {
         return(-1);
     }
 }
Ejemplo n.º 19
0
 public static bool Update(BookingView b)
 {
     try
     {
         db = new AceEntities();
         Booking book = db.Booking.Find(b.Id);
         book.IdCustomer = b.CusID;
         book.RoomId     = b.RoomID;
         book.Status     = b.Status;
         book.DateEnd    = b.DateEnd;
         book.DateStart  = b.DateStart;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 20
0
 public static bool Modify(ServicesView s)
 {
     try
     {
         db = new AceEntities();
         Services services = new Services
         {
             Name  = s.Name,
             Price = s.Price
         };
         db.Services.Attach(services);
         db.Entry(services).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 21
0
 public static bool Modify(RoomView r)
 {
     try
     {
         db = new AceEntities();
         Room room = new Room
         {
             IdEmp = r.EmpID,
             Name  = Convert.ToInt32(r.Name.Trim()),
             Price = r.Price,
         };
         db.Room.Attach(room);
         db.Entry(room).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 22
0
 public static bool Modify(AccountView acc)
 {
     try
     {
         db = new AceEntities();
         Account account = new Account
         {
             Name     = acc.Name,
             Email    = acc.Email,
             Address  = acc.Address,
             Password = acc.Password,
             Phone    = acc.Phone,
             Roles    = acc.Role
         };
         db.Account.Attach(account);
         db.Entry(account).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 23
0
 public static int Create(OrderView o)
 {
     try
     {
         db = new AceEntities();
         Orders orders = new Orders
         {
             Date      = o.Date,
             DateEnd   = o.DateEnd,
             DateStart = o.DateStart,
             IdCus     = o.CusID,
             IdEmp     = o.EmpID,
             IdRoom    = o.RoomID,
             Total     = o.Total
         };
         db.Orders.Add(orders);
         db.SaveChanges();
         return(orders.Id);
     }
     catch
     {
         return(-1);
     }
 }