// GET: Employees

        private IEnumerable <ViewModels.EmployeeViewModel> GetEmployees()
        {
            return((from c in XpoSession.Query <Models.Employee>().ToList()
                    select new ViewModels.EmployeeViewModel()
            {
                ID = c.Oid, Name = c.Name, DateOfBirth = c.DateOfBirth, Age = c.Age
            }).ToList());
        }
 private void CreateDataSource()
 {
     if (XpoSession != null)
     {
         Type xpoType = Type.GetType(XpoClassName, true);
         this.DataSource = new XPCollection(XpoSession, XpoSession.GetClassInfo(xpoType));
     }
 }
 IEnumerable <CustomerViewModel> GetCustomers()
 {
     return((from c in XpoSession.Query <Customer>().ToList()
             select new CustomerViewModel()
     {
         ID = c.Oid, Name = c.Name
     }).ToList());
 }
 IEnumerable <RoleViewModel> GetRoles()
 {
     return((from c in XpoSession.Query <XpoApplicationRole>().ToList()
             select new RoleViewModel()
     {
         ID = c.Id, Name = c.Name, NameUpper = c.NameUpper
     }).ToList());
 }
예제 #5
0
 public IEnumerable GetResources()
 {
     return((from r in XpoSession.Query <XPResource>().ToList()
             select new XPResourceViewModel()
     {
         ID = r.Oid, Name = r.Name
     }).ToList());
 }
        public ActionResult GridViewPartialDelete([ModelBinder(typeof(DevExpressEditorsBinder))] RoleViewModel role)
        {
            var appRole = XpoSession.GetObjectByKey <XpoApplicationRole>(role.ID);

            if (appRole != null)
            {
                XpoSession.Delete(appRole);
                XpoSession.CommitChanges();
            }
            return(PartialView("_GridViewPartial", GetRoles()));
        }
        void SaveRole(ApplicationRole applicationRole)
        {
            XpoApplicationRole role = XpoSession.GetObjectByKey <XpoApplicationRole>(applicationRole.ID);

            if (role == null)
            {
                role = new XpoApplicationRole(XpoSession);
            }
            role.Name = applicationRole.Name;
            XpoSession.CommitChanges();
        }
예제 #8
0
 public IEnumerable GetAppointments()
 {
     return((from a in XpoSession.Query <XPAppointment>().ToList()
             select new XPAppointmentViewModel()
     {
         ID = a.Oid, Subject = a.Subject, Created = a.Created, Finish = a.Finish,
         AllDay = a.AllDay, Location = a.Location, Description = a.Description,
         Label = a.Label, Status = a.Status, ResourceIds = a.ResourceIds,
         Recurrence = a.Recurrence, AppointmentType = a.AppointmentType,
         Reminder = a.Reminder
     }).ToList());
 }
        public ActionResult GridViewPartialAddNewOrUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] RoleViewModel role)
        {
            var appRole = XpoSession.Query <XpoApplicationRole>().FirstOrDefault(x => x.NameUpper == role.Name.ToUpper());

            if (appRole == null)
            {
                appRole = new XpoApplicationRole(XpoSession);
            }
            appRole.Name = role.Name;
            XpoSession.CommitChanges();

            return(PartialView("_GridViewPartial", GetRoles()));
        }
예제 #10
0
 IEnumerable <UserViewModel> GetUsers()
 {
     return((from c in XpoSession.Query <XpoApplicationUser>().ToList()
             select new UserViewModel()
     {
         UserName = c.UserName,
         Email = c.Email,
         Roles = c.Roles.Select(t => new RoleViewModel {
             ID = t.ID, Name = t.Name
         }).ToList(),
         RoleName = string.Join(", ", c.Roles.Select(t => t.Name).ToArray())
     }).ToList());
 }
예제 #11
0
        IEnumerable <CustomerViewModel> GetCustomers()
        {
            var result = (from c in XpoSession.Query <XPOCustomer>().ToList()
                          select new CustomerViewModel()
            {
                CustomerId = c.CustomerId,
                DisplayText = String.Format("{0}, {1}", c.LastName, c.FirstName),
                FirstName = c.FirstName,
                LastName = c.LastName,
                Company = c.Company
            }
                          ).ToList();

            return(result);
        }
예제 #12
0
        private IdentityResult UpdateRole(string userId, string roleName)
        {
            var user = UserManager.FindById(userId);
            //RemovePreviousRoles(user);
            //if role does not exist then add the role
            XpoApplicationRole role = XpoSession.Query <XpoApplicationRole>()?.FirstOrDefault(x => x.Name == roleName);

            if (role == null)
            {
                role      = new XpoApplicationRole(XpoSession);
                role.Name = roleName;
                XpoSession.CommitChanges();
            }

            return(UserManager.AddToRole(user.Id, roleName));
        }
 OrdersViewModel GetOrders()
 {
     return(new OrdersViewModel()
     {
         Source = (from o in XpoSession.Query <Order>().ToList()
                   select new OrderViewModel()
         {
             ID = o.Oid, Name = o.Name, Customer = o.Customer.Oid
         }).ToList(),
         CustomersLookUpData = (from c in XpoSession.Query <Customer>().ToList()
                                select new CustomerViewModel()
         {
             ID = c.Oid, Name = c.Name
         }).ToList()
     });
 }
예제 #14
0
        IEnumerable <InvoiceViewModel> GetItems()
        {
            var result = (from c in XpoSession.Query <XPOInvoice>().ToList()
                          select new InvoiceViewModel()
            {
                InvoiceId = c.InvoiceId,
                CustomerId = (c.CustomerId == null) ? 0 : (c.CustomerKey),
                InvoiceDate = c.InvoiceDate,
                BillingAddress = c.BillingAddress,
                BillingCity = c.BillingCity,
                BillingState = c.BillingState,
                BillingCountry = c.BillingCountry,
                BillingPostalCode = c.BillingPostalCode,
                Total = c.Total
            }).ToList();

            return(result);
        }