Пример #1
0
        public static User LoadById(Guid id)
        {
            try
            {
                using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities())
                {
                    tblUser userRow = dc.tblUsers.FirstOrDefault(a => a.Id == id);

                    if (userRow != null)
                    {
                        return(new User
                        {
                            Id = userRow.Id,
                            FirstName = userRow.FirstName,
                            LastName = userRow.LastName,
                            Email = userRow.Email,
                            Phone = userRow.Phone,
                            Password = userRow.Password,
                            Addresses = UserAddressManager.LoadByUserId(id),
                            Payments = UserPaymentManager.LoadByUserId(id)
                        });
                    }

                    else
                    {
                        throw new Exception("Row not found...");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        public static User LoadByEmail(string email, string password)
        {
            try
            {
                using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities())
                {
                    tblUser userRow = dc.tblUsers.FirstOrDefault(a => a.Email == email && a.Password == password);

                    if (userRow != null)
                    {
                        return(new User
                        {
                            Id = userRow.Id,
                            FirstName = userRow.FirstName,
                            LastName = userRow.LastName,
                            Email = userRow.Email,
                            Phone = userRow.Phone,
                            Password = userRow.Password,
                            Addresses = UserAddressManager.LoadByUserId(userRow.Id),
                            Payments = UserPaymentManager.LoadByUserId(userRow.Id)
                        });
                    }

                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
        public static List <User> Load()
        {
            try
            {
                using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities())
                {
                    List <User> results = new List <User>();
                    dc.tblUsers.ToList().ForEach(p => results.Add(new User
                    {
                        Id        = p.Id,
                        FirstName = p.FirstName,
                        LastName  = p.LastName,
                        Email     = p.Email,
                        Phone     = p.Phone,
                        Password  = p.Password,
                        Addresses = UserAddressManager.LoadByUserId(p.Id),
                        Payments  = UserPaymentManager.LoadByUserId(p.Id)
                    }));


                    return(results);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }