Exemplo n.º 1
0
        public Portfolio AddPortfolio(Portfolio portfolio)
        {
            try
            {
                using (ApplicationUnit unit = new ApplicationUnit())
                {
                    Client client = unit.Clients.GetAll()
                                    .FirstOrDefault(u => u.Id == portfolio.Client.Id);

                    Portfolio hasPortfolio = unit.Portfolios.GetAll()
                                             .FirstOrDefault(u => u.Name.ToLower() == portfolio.Name.ToLower());

                    if (hasPortfolio == null)
                    {
                        portfolio.Client = client;
                        unit.Portfolios.Add(portfolio);
                        unit.SaveChanges();
                        return(portfolio);
                    }
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public Facility AddFacility(Facility facility)
        {
            try
            {
                using (ApplicationUnit unit = new ApplicationUnit())
                {
                    Portfolio portfolio = unit.Portfolios.GetAll()
                                          .FirstOrDefault(p => p.Id == facility.Portfolio.Id);

                    Facility hasFacility = unit.Facilities.GetAll()
                                           .FirstOrDefault(u => u.Name.ToLower() == facility.Name.ToLower());


                    if (hasFacility == null)
                    {
                        facility.CreatedDate  = DateTime.Now;
                        facility.ModifiedDate = DateTime.Now;
                        facility.Portfolio    = portfolio;
                        facility.Status       = "New";
                        unit.Facilities.Add(facility);
                        unit.SaveChanges();
                        return(facility);
                    }
                    return(null);
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.LogError(ex.StackTrace, "AddFacility");
                throw ex;
            }
        }
        public HttpResponseMessage Put(int id, Home home)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
            }

            if (id != home.Id)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            Home existingHome = _unit.Homes.GetById(id);

            _unit.Homes.Detach(existingHome);

            // Keep original CreatedOn
            home.CreatedOn = existingHome.CreatedOn;

            _unit.Homes.Update(home);

            try
            {
                _unit.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, "{success:'true', verb:'PUT'}"));
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Exemplo n.º 4
0
        public ActionResult UploadImage(HttpPostedFileBase image, int id)
        {
            JsonResult result;
            Home       home;
            Random     rand = new Random();
            string     unique;
            string     ext;
            string     fileName;
            string     path;

            unique = rand.Next(1000000).ToString();

            ext = Path.GetExtension(image.FileName).ToLower();

            fileName = string.Format("{0}-{1}{2}", id, unique, ext);

            path = Path.Combine(
                HttpContext.Server.MapPath(Config.ImagesFolderPath), fileName);

            if (ext == ".png" || ext == ".jpg")
            {
                home = _unit.Homes.GetById(id);

                if (home != null)
                {
                    home.ImageName = fileName;
                    _unit.Homes.Update(home);
                    _unit.SaveChanges();

                    image.SaveAs(path);
                    result = this.Json(new
                    {
                        imageUrl = string.Format("{0}{1}",
                                                 Config.ImagesUrlPrefix, fileName)
                    });
                }
                else
                {
                    result = this.Json(new
                    {
                        status     = "error",
                        statusText =
                            string.Format("There is no home with the Id of " +
                                          "'{0}' in the system.", id)
                    });
                }
            }
            else
            {
                result = this.Json(new
                {
                    status     = "error",
                    statusText = "Unsupported image type. Only .png or " +
                                 ".jpg files are acceptable."
                });
            }

            return(result);
        }
 private void CreateEditBoundryPolygon(List <BoundryPolygon> boundryPolygons, ref ApplicationUnit unit, Location location)
 {
     foreach (var boundryPolygon in boundryPolygons)
     {
         boundryPolygon.Location = location;
         location.BoundryPolygon.Add(boundryPolygon);
     }
     unit.SaveChanges();
 }
        /// <summary>
        /// Log error
        /// </summary>
        /// <param name="errorLog"></param>
        /// <returns></returns>
        public async Task Log(ErrorLog errorLog)
        {
            ApplicationUnit unit = new ApplicationUnit();

            Model.ErrorLog errorLogd = new Model.ErrorLog();
            errorLogd.ErrorMessage = errorLog.ErrorMessage;
            errorLogd.Source       = errorLog.Source;
            errorLogd.Date         = errorLog.Date;
            unit.ErrorLogs.Add(errorLogd);
            unit.SaveChanges();
        }
 private void CreateEditGPSCoordinates(GPSCoordinate GPSCoordinates, ref ApplicationUnit unit)
 {
     if (GPSCoordinates.Id != 0)
     {
         unit.GPSCoordinates.Update(GPSCoordinates);
     }
     else
     {
         unit.GPSCoordinates.Add(GPSCoordinates);
     }
     unit.SaveChanges();
 }
Exemplo n.º 8
0
 public static void LogError(string errorMessase, string source)
 {
     using (ApplicationUnit unit = new ApplicationUnit())
     {
         ErrorLog errorLog = new ErrorLog
         {
             Date         = DateTime.Now,
             ErrorMessage = errorMessase,
             Source       = source
         };
         unit.ErrorLogs.Add(errorLog);
         unit.SaveChanges();
     }
 }
        public HttpResponseMessage UpdateBuilding(Building building)
        {
            ApplicationUnit unit = new ApplicationUnit();

            try
            {
                Building updateBudilng = unit.Buildings.GetAll().FirstOrDefault(fc => fc.Id == building.Id);
                if (updateBudilng != null)
                {
                    updateBudilng.BuildingName            = building.BuildingName.Trim();
                    updateBudilng.BuildingNumber          = building.BuildingNumber.Trim();
                    updateBudilng.BuildingType            = building.BuildingType.Trim();
                    updateBudilng.BuildingStandard        = building.BuildingStandard.Trim();
                    updateBudilng.Status                  = building.Status.Trim();
                    updateBudilng.GPSCoordinates          = GPSCoordinates(building.GPSCoordinates, ref unit);
                    updateBudilng.NumberOfFloors          = building.NumberOfFloors;
                    updateBudilng.FootPrintArea           = building.FootPrintArea;
                    updateBudilng.ImprovedArea            = building.ImprovedArea;
                    updateBudilng.Heritage                = building.Heritage;
                    updateBudilng.OccupationYear          = building.OccupationYear;
                    updateBudilng.DisabledAccess          = building.DisabledAccess.Trim();
                    updateBudilng.DisabledComment         = building.DisabledComment.Trim();
                    updateBudilng.ConstructionDescription = building.ConstructionDescription;
                    updateBudilng.Photo        = building.Photo;
                    updateBudilng.ModifiedDate = DateTime.Now;

                    unit.Buildings.Update(updateBudilng);
                    unit.SaveChanges();

                    int  userId     = updateBudilng.ModifiedUserId != null ? updateBudilng.ModifiedUserId.Value : 0;
                    Task updateTask = new Task(() => LogAuditTrail("Building", "Update", userId, updateBudilng.Id));
                    updateTask.Start();

                    building.Facility = null;
                    return(Request.CreateResponse(HttpStatusCode.OK, new
                    {
                        content = building
                    }));
                }
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                unit.Dispose();
                ErrorHandling.LogError(ex.StackTrace, "UpdateBuilding");
                return(Request.CreateResponse(ex));
            }
        }
        public HttpResponseMessage AddBuilding(Building building)
        {
            try
            {
                using (ApplicationUnit unit = new ApplicationUnit())
                {
                    Facility facility = unit.Facilities.GetAll().Include(b => b.Buildings)
                                        .FirstOrDefault(fc => fc.Id == building.Facility.Id);

                    if (facility != null)
                    {
                        bool hasBuilding = facility.Buildings.Exists(b => b.BuildingName == building.BuildingName);
                        if (!hasBuilding)
                        {
                            building.BuildingName     = building.BuildingName.Trim();
                            building.BuildingNumber   = building.BuildingNumber.Trim();
                            building.BuildingType     = building.BuildingType.Trim();
                            building.DisabledAccess   = building.DisabledAccess.Trim();
                            building.DisabledComment  = building.DisabledComment.Trim();
                            building.BuildingStandard = building.BuildingStandard.Trim();
                            building.Status           = building.Status.Trim();
                            building.Facility         = facility;
                            building.CreatedDate      = DateTime.Now;
                            building.ModifiedDate     = DateTime.Now;
                            unit.Buildings.Add(building);

                            unit.SaveChanges();
                            building.Facility = null;

                            Task addTask = new Task(() => LogAuditTrail("Building", "Add", building.CreatedUserId, building.Id));
                            addTask.Start();

                            return(Request.CreateResponse(HttpStatusCode.OK, new
                            {
                                content = building
                            }));
                        }
                    }
                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.LogError(ex.StackTrace, "AddBuilding");
                return(Request.CreateResponse(ex));
            }
        }
Exemplo n.º 11
0
        public HttpResponseMessage UpdateFacility(Facility facility)
        {
            ApplicationUnit unit = new ApplicationUnit();

            Facility updateFacility = unit.Facilities.GetAll().FirstOrDefault(fc => fc.Id == facility.Id);

            try
            {
                if (updateFacility != null)
                {
                    updateFacility.SettlementType = facility.SettlementType;
                    updateFacility.Zoning         = facility.Zoning;
                    updateFacility.Name           = facility.Name;
                    updateFacility.IDPicture      = facility.IDPicture;
                    updateFacility.Status         = facility.Status;
                    updateFacility.ModifiedUserId = facility.ModifiedUserId;
                    updateFacility.ModifiedDate   = DateTime.Now;

                    unit.Facilities.Update(updateFacility);
                    unit.SaveChanges();
                    unit.Dispose();

                    int  userId     = updateFacility.ModifiedUserId != null ? facility.ModifiedUserId.Value : 0;
                    Task updateTask = new Task(() => LogAuditTrail("Facility", "Update", userId, updateFacility.Id));
                    updateTask.Start();

                    return(Request.CreateResponse(HttpStatusCode.OK, new
                    {
                        content = true
                    }));
                }
                return(Request.CreateResponse(HttpStatusCode.OK, new
                {
                    content = true
                }));
            }
            catch (Exception ex)
            {
                unit.Dispose();
                ErrorHandling.LogError(ex.StackTrace, "UpdateFacility");
                return(Request.CreateResponse(ex));
            }
        }
        public Client AddClient(Client client)
        {
            using (ApplicationUnit unit = new ApplicationUnit())
            {
                Client hasClient = unit.Clients.GetAll()
                                   .FirstOrDefault(cl => cl.ClientId.ToLower() == client.ClientId.ToLower());

                if (hasClient == null)
                {
                    client.CreatedDate  = DateTime.Now;
                    client.ModifiedDate = DateTime.Now;

                    unit.Clients.Add(client);
                    unit.SaveChanges();
                    return(client);
                }
                return(null);
            }
        }
        public User AddUser(User user)
        {
            using (ApplicationUnit unit = new ApplicationUnit())
            {
                User loginUser = unit.Users.GetAll()
                                 .FirstOrDefault(usr => usr.Username.ToLower() == user.Username.ToLower());

                if (loginUser == null)
                {
                    string password = EncryptString.Encrypt(user.Password, "THEPROJECT");
                    user.Password     = password;
                    user.CreatedDate  = DateTime.Now;
                    user.ModifiedDate = DateTime.Now;
                    unit.Users.Add(user);
                    unit.SaveChanges();
                    return(user);
                }
                return(null);
            }
        }
Exemplo n.º 14
0
 private void LogAuditTrail(string section, string type, int userId, int itemId)
 {
     try
     {
         using (ApplicationUnit unit = new ApplicationUnit())
         {
             Audit audit = new Audit
             {
                 ChangeDate = DateTime.Now,
                 ItemId     = itemId,
                 Section    = section,
                 UserId     = userId,
                 Type       = type
             };
             unit.Audits.Add(audit);
             unit.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 15
0
        public Technician CreateTechnicianAccount(Technician technician)
        {
            using (ApplicationUnit unit = new ApplicationUnit())
            {
                Technician hasUser = unit.Technicians.GetAll().FirstOrDefault(u => u.CellNo.ToLower() == technician.CellNo.ToLower());
                if (hasUser == null)
                {
                    string password = Encryption.Encrypt(technician.Password, "BusinessPortal");
                    technician.Password = password;
                    technician.Role     = "Technician";
                    unit.Technicians.Add(technician);
                    unit.SaveChanges();

                    //Send Message to user
                    //EmailService emailService = new EmailService();
                    //Task sendEmailTask = new Task(() => emailService.SendWelcomeEmail(user.Email));
                    //sendEmailTask.Start();

                    return(technician);
                }
                return(null);
            }
        }
        private void CreateK2UKApp()
        {
            //Database.SetInitializer(new DropCreateDatabaseAlways<K2Field.SmartForms.Workspace.Model.WorkspaceContext>());

            using (var unit = new ApplicationUnit())
            {
                Data.WorkspaceUser u = new Data.WorkspaceUser()
                {
                    Username    = @"denallix\administrator",
                    FQN         = @"denallix\administrator",
                    DisplayName = "Administrator",
                    Email       = "*****@*****.**",
                    IsActive    = true
                };


                ObservableCollection <Data.WorkspaceUser> r = new ObservableCollection <Data.WorkspaceUser>();
                r.Add(u);

                Data.WorkspaceTeam scna = new Data.WorkspaceTeam()
                {
                    Name           = "scna",
                    DisplayName    = "K2 SCNA",
                    Description    = "K2 North American Team",
                    IsActive       = true,
                    WorkspaceUsers = r,
                };

                Data.WorkspaceTeam scuk = new Data.WorkspaceTeam()
                {
                    Name           = "scuk",
                    DisplayName    = "K2 SCUK",
                    Description    = "K2 UK Europe Team",
                    IsActive       = true,
                    WorkspaceUsers = r,
                };

                Data.WorkspaceLink link1a = new Data.WorkspaceLink()
                {
                    Name        = "mytasks",
                    DisplayName = "My Tasks",
                    IsEnabled   = true,
                    IsSmartForm = true,
                    Level       = 1,
                    Url         = "https://k2.denallix.com/Runtime/Runtime/Form/Worklist/",
                    Type        = "Link",
                    Icon        = "fa fa-male fa-fw",
                    MinHeight   = 400
                };

                Data.WorkspaceLink link1b = new Data.WorkspaceLink()
                {
                    Name        = "teamtasks",
                    DisplayName = "Team Tasks",
                    IsEnabled   = true,
                    IsSmartForm = true,
                    Level       = 1,
                    Url         = "https://k2.denallix.com/Runtime/Runtime/Form/Worklist/",
                    Type        = "Link",
                    Icon        = "fa fa-group fa-fw",
                    MinHeight   = 400
                };

                Data.WorkspaceLink link1c = new Data.WorkspaceLink()
                {
                    Name        = "servicetasks",
                    DisplayName = "Service Tasks",
                    IsEnabled   = true,
                    IsSmartForm = true,
                    Level       = 1,
                    Url         = "https://k2.denallix.com/Runtime/Runtime/Form/Worklist/",
                    Type        = "Link",
                    Icon        = "fa fa-sort-amount-asc fa-fw",
                    MinHeight   = 400
                };

                ObservableCollection <Data.WorkspaceLink> tasks = new ObservableCollection <Data.WorkspaceLink>();
                tasks.Add(link1a);
                tasks.Add(link1b);
                tasks.Add(link1c);

                Data.WorkspaceLink link1 = new Data.WorkspaceLink()
                {
                    Name        = "tasks",
                    DisplayName = "Tasks",
                    IsEnabled   = true,
                    IsSmartForm = false,
                    Level       = 0,
                    Type        = "Heading",
                    ChildLinks  = tasks,
                    Icon        = "fa fa-tasks fa-fw",
                };


                Data.WorkspaceLink link2 = new Data.WorkspaceLink()
                {
                    Name        = "apps",
                    DisplayName = "Apps",
                    IsEnabled   = true,
                    IsSmartForm = false,
                    Level       = 0,
                    //Url = "https://k2.denallix.com/Runtime/Runtime/View/Demo+CRM+Account+List/",
                    Type      = "Heading",
                    Icon      = "fa fa-cogs fa-fw",
                    MinHeight = 500
                };

                Data.WorkspaceLink taskalloc = new Data.WorkspaceLink()
                {
                    Name        = "taskallocation",
                    DisplayName = "Task Allocation",
                    Description = "Allocate a managed tasks to users",
                    IsEnabled   = true,
                    IsSmartForm = true,
                    Level       = 1,
                    Url         = "https://k2.denallix.com/runtime/runtime/form/cm.task__create.form/?_theme=jove1",
                    Type        = "Link",
                    Icon        = "fa fa-sitemap fa-fw",
                    MinHeight   = 500,
                    Sequence    = 0,
                };

                Data.WorkspaceLink sendmessage = new Data.WorkspaceLink()
                {
                    Name        = "sendmessage",
                    DisplayName = "Send Message",
                    Description = "Send a tracked email or SMS message",
                    IsEnabled   = true,
                    IsSmartForm = true,
                    Level       = 1,
                    Url         = "https://k2.denallix.com/runtime/runtime/form/cm.sendmessage.form/?_theme=jove1",
                    Type        = "Link",
                    Icon        = "fa fa-paper-plane fa-fw",
                    MinHeight   = 500,
                    Sequence    = 0,
                };

                Data.WorkspaceLink customerfeedback = new Data.WorkspaceLink()
                {
                    Name        = "customerfeedback",
                    DisplayName = "Customer Feedback",
                    Description = "Record and manage customer feedback",
                    IsEnabled   = true,
                    IsSmartForm = true,
                    Level       = 1,
                    Url         = "https://k2.denallix.com/runtime/runtime/form/newportal__denallix__com__sales__lists__customer__feedbacktaskform/?_theme=jove1",
                    Type        = "Link",
                    Icon        = "fa fa-rocket fa-fw",
                    MinHeight   = 500,
                    Sequence    = 0,
                };

                Data.WorkspaceLink logaconversation = new Data.WorkspaceLink()
                {
                    Name        = "logaconversation",
                    DisplayName = "Log a Conversation",
                    Description = "Log a conversation with an employee or customer",
                    IsEnabled   = true,
                    IsSmartForm = true,
                    Level       = 1,
                    Url         = "https://k2.denallix.com/runtime/runtime/form/cm.logconversation.form/",
                    Type        = "Link",
                    Icon        = "fa fa-wechat fa-fw",
                    MinHeight   = 500,
                    Sequence    = 0,
                };

                Data.WorkspaceLink employeeonboarding = new Data.WorkspaceLink()
                {
                    Name        = "employeeonboarding",
                    DisplayName = "Employee Onboarding",
                    Description = "Onboard a new employee",
                    IsEnabled   = true,
                    IsSmartForm = true,
                    Level       = 1,
                    Url         = "https://k2.denallix.com/runtime/runtime/form/eo.submitnewemployee.form/",
                    Type        = "Link",
                    Icon        = "fa fa-desktop fa-fw",
                    MinHeight   = 500,
                    Sequence    = 0,
                };

                Data.WorkspaceLink raiseapurchaseorder = new Data.WorkspaceLink()
                {
                    Name        = "raiseapurchaseorder",
                    DisplayName = "Raise Purchase Order",
                    Description = "Raise new purchase order",
                    IsEnabled   = true,
                    IsSmartForm = true,
                    Level       = 1,
                    Url         = "https://k2.denallix.com/runtime/runtime/form/po.raisenewpo.form/?_theme=jove1",
                    Type        = "Link",
                    Icon        = "fa fa-usd fa-fw",
                    MinHeight   = 500,
                    Sequence    = 0,
                };

                ObservableCollection <Data.WorkspaceLink> apps = new ObservableCollection <Data.WorkspaceLink>();
                apps.Add(taskalloc);
                apps.Add(sendmessage);
                apps.Add(customerfeedback);
                apps.Add(logaconversation);
                apps.Add(employeeonboarding);
                apps.Add(raiseapurchaseorder);

                link2.ChildLinks = apps;

                Data.WorkspaceLink link3 = new Data.WorkspaceLink()
                {
                    Name        = "dashboards",
                    DisplayName = "Dashboards",
                    IsEnabled   = true,
                    IsSmartForm = false,
                    Level       = 0,
                    Type        = "Heading",
                    Icon        = "fa fa-dashboard fa-fw",
                    MinHeight   = 500,
                    Sequence    = 2,
                };


                Data.WorkspaceLink chart1 = new Data.WorkspaceLink()
                {
                    Name        = "chart1",
                    DisplayName = "Org KPI ",
                    Description = "Organization wide KPIs",
                    IsEnabled   = true,
                    IsSmartForm = true,
                    Level       = 1,
                    Url         = "https://k2.denallix.com/runtime/runtime/form/po.raisenewpo.form/?_theme=jove1",
                    Type        = "Link",
                    Icon        = "fa fa-area-chart fa-fw",
                    MinHeight   = 500,
                    Sequence    = 0,
                };


                Data.WorkspaceLink chart2 = new Data.WorkspaceLink()
                {
                    Name        = "chart2",
                    DisplayName = "Task Dashboard ",
                    Description = "Task Dashboard",
                    IsEnabled   = true,
                    IsSmartForm = true,
                    Level       = 1,
                    Url         = "https://k2.denallix.com/runtime/runtime/form/po.raisenewpo.form/?_theme=jove1",
                    Type        = "Link",
                    Icon        = "fa fa-line-chart fa-fw",
                    MinHeight   = 500,
                    Sequence    = 0,
                };

                Data.WorkspaceLink chart3 = new Data.WorkspaceLink()
                {
                    Name        = "chart3",
                    DisplayName = "Customer Service Dashboard ",
                    Description = "Customer Service  Dashboard",
                    IsEnabled   = true,
                    IsSmartForm = true,
                    Level       = 1,
                    Url         = "https://k2.denallix.com/runtime/runtime/form/po.raisenewpo.form/?_theme=jove1",
                    Type        = "Link",
                    Icon        = "fa fa-pie-chart fa-fw",
                    MinHeight   = 500,
                    Sequence    = 0,
                };

                ObservableCollection <Data.WorkspaceLink> dash = new ObservableCollection <Data.WorkspaceLink>();
                dash.Add(chart1);
                dash.Add(chart2);
                dash.Add(chart3);

                link3.ChildLinks = dash;

                ObservableCollection <Data.WorkspaceLink> headings = new ObservableCollection <Data.WorkspaceLink>();
                headings.Add(link1);
                headings.Add(link2);
                headings.Add(link3);

                //Url = "https://k2.denallix.com/Runtime/Runtime/View/Demo+CRM+Account+List/",


                //unit.WorklistUsers.Add(u);


                Data.Workspace w = new Data.Workspace()
                {
                    DisplayName          = "K2 Workdesk",
                    Name                 = "K2workdesk",
                    Description          = "K2 Workdesk description....",
                    SmartFormsRuntimeUrl = "https://k2.denallix.com/runtime/",
                    Links                = headings,
                    Icon                 = "fa fa-suitcase fa-2x",
                };



                ObservableCollection <Data.WorkspaceLink> headings1 = new ObservableCollection <Data.WorkspaceLink>();
                headings1.Add(link1a);
                headings1.Add(link1b);
                headings1.Add(link1c);
                headings1.Add(chart1);
                headings1.Add(chart2);

                Data.Workspace w1 = new Data.Workspace()
                {
                    DisplayName          = "Task Management",
                    Name                 = "taskmanagement",
                    Description          = "Task Management workdesk description...",
                    SmartFormsRuntimeUrl = "https://k2.denallix.com/runtime/",
                    Links                = headings1,
                    Icon                 = "fa fa-share-alt fa-2x",
                };


                Data.WorkspaceLink linkservice = new Data.WorkspaceLink()
                {
                    Name        = "serviceapps",
                    DisplayName = "Service Apps",
                    IsEnabled   = true,
                    IsSmartForm = false,
                    Level       = 0,
                    //Url = "https://k2.denallix.com/Runtime/Runtime/View/Demo+CRM+Account+List/",
                    Type      = "Heading",
                    Icon      = "fa fa-cogs fa-fw",
                    MinHeight = 500
                };

                ObservableCollection <Data.WorkspaceLink> serviceapps = new ObservableCollection <Data.WorkspaceLink>();
                serviceapps.Add(customerfeedback);
                serviceapps.Add(sendmessage);
                serviceapps.Add(logaconversation);
                serviceapps.Add(taskalloc);

                linkservice.ChildLinks = serviceapps;

                ObservableCollection <Data.WorkspaceLink> headings2 = new ObservableCollection <Data.WorkspaceLink>();
                headings2.Add(link1a);
                headings2.Add(link1b);
                headings2.Add(linkservice);
                headings2.Add(chart1);
                headings2.Add(chart3);


                Data.Workspace w2 = new Data.Workspace()
                {
                    DisplayName          = "Service Desks",
                    Name                 = "servicedesk",
                    Description          = "Customer Service Desk description...",
                    SmartFormsRuntimeUrl = "https://k2.denallix.com/runtime/",
                    Links                = headings2,
                    Icon                 = "fa fa-trophy fa-2x",
                };

                w.WorkspaceTeams = new ObservableCollection <Data.WorkspaceTeam>();
                w.WorkspaceTeams.Add(scna);
                w.WorkspaceTeams.Add(scuk);

                w1.WorkspaceTeams = new ObservableCollection <Data.WorkspaceTeam>();
                w1.WorkspaceTeams.Add(scna);
                w1.WorkspaceTeams.Add(scuk);

                w2.WorkspaceTeams = new ObservableCollection <Data.WorkspaceTeam>();
                w2.WorkspaceTeams.Add(scna);
                w2.WorkspaceTeams.Add(scuk);

                //unit.WorkspaceTeams.Add(t);
                unit.Workspaces.Add(w);
                unit.Workspaces.Add(w1);
                unit.Workspaces.Add(w2);

                int rows = unit.SaveChanges();
                MessageBox.Show("Rows: " + rows);
            }
        }