Ejemplo n.º 1
0
        public ActionResult Create()
        {
            var householdViewModel = new MainDashboardViewModel();

            if (householdViewModel.Household == null)
            {
                return(RedirectToAction("Index", "Households"));
            }
            if (householdViewModel.BankAccounts.Count == 0)
            {
                return(RedirectToAction("Create", "BankAccounts"));
            }
            if (householdViewModel.Budgets.Count == 0)
            {
                return(RedirectToAction("Create", "Budgets"));
            }
            if (householdViewModel.BudgetItems.Count == 0)
            {
                return(RedirectToAction("Create", "BudgetItems"));
            }
            ViewBag.BankAccountId     = new SelectList(householdViewModel.BankAccounts, "Id", "Name");
            ViewBag.BudgetItemId      = new SelectList(householdViewModel.BudgetItems, "Id", "Name");
            ViewBag.TransactionTypeId = new SelectList(_db.TransactionTypes, "Id", "Type");
            return(View());
        }
Ejemplo n.º 2
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            IoC.RegisterServices();

            _userRepository = IoC.Resolve <IUserRepository>();

            try
            {
                UserInfo userInfo = await _userRepository.GetUserInfo();

                var vm = new MainDashboardViewModel(userInfo.CalculateSummary(), _userRepository,
                                                    IoC.Resolve <IWindowService>());
                new MainDashboard(vm).Show();
            }
            catch (FileNotFoundException)
            {
                InitialSetup();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Application could not start due to a fatal error:\n\n{ex.Message}", "Fatal Error",
                                MessageBoxButton.OK, MessageBoxImage.Error);

                Current.Shutdown();
            }
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BudgetItem budgetItem = _db.BudgetItems.Find(id);

            if (budgetItem == null)
            {
                return(HttpNotFound());
            }

            budgetItem.Budget = _db.Budgets.Find(budgetItem.BudgetId);
            if (budgetItem.Budget == null)
            {
                return(RedirectToAction("Index", "Households"));
            }

            var currentUserHouseholdId = Helpers.HelperMethods.GetCurrentUserHouseholdId();

            if (currentUserHouseholdId == null || budgetItem.Budget.HouseholdId != currentUserHouseholdId)
            {
                return(RedirectToAction("Index", "Households"));
            }
            var householdViewModel = new MainDashboardViewModel();

            if (householdViewModel.Budgets.Count == 0)
            {
                return(RedirectToAction("Create", "Budgets"));
            }
            ViewBag.BudgetId = new SelectList(householdViewModel.Budgets, "Id", "Name");
            return(View(budgetItem));
        }
Ejemplo n.º 4
0
        public JsonResult GetTicketTypes()
        {
            var           ticketTypesBarChart = new TicketTypes();
            var           viewModel           = new MainDashboardViewModel();
            List <Ticket> allTickets          = viewModel.AllTickets;

            if (allTickets.Count > 0)
            {
                Dictionary <string, int> ticketStatusCounts = new Dictionary <string, int>();
                foreach (var status in ticketTypesBarChart.labels)
                {
                    ticketStatusCounts[status] = 0;
                }
                foreach (var ticket in allTickets)
                {
                    ticketStatusCounts[ticket.TicketStatus.Name]++;
                }

                for (int i = 0; i < ticketTypesBarChart.labels.Length; i++)
                {
                    float percentage = (float)100 * ticketStatusCounts[ticketTypesBarChart.labels[i]] / allTickets.Count;
                    percentage = (float)Math.Round(percentage);
                    ticketTypesBarChart.values[i] = (int)percentage;
                }
            }
            return(Json(ticketTypesBarChart));
        }
Ejemplo n.º 5
0
        public MainDashboardViewModel GetMainDashboardModel()
        {
            IEnumerable <DogOwnerLookingForDogSitter> GetMainMessages()
            {
                return(mainMessageBoardRepo.GetUnansweredMessagesWithDogs().Select(m => new DogOwnerLookingForDogSitter()
                {
                    MainBoardID = m.MainBoardID,
                    RequestMessage = m.RequestMessage,

                    RequestSender = m.DogOwnerID,
                    RequestSenderFullName = m.RequestSender.FullName,
                    RequestSenderPhoneNumber = m.RequestSender.PhoneNumber,

                    DogID = m.DogID,
                    DogName = m.Dog.DogName,
                    DogSize = m.Dog.DogSize,
                    Description = m.Dog.Description,
                }));
            }

            MainDashboardViewModel mainDashboardViewModel = new MainDashboardViewModel()
            {
                MainMessages = GetMainMessages()
            };

            return(mainDashboardViewModel);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Function for creating User Dashboard View Model
        /// </summary>
        /// <param name="projectsList">Projects list from Database</param>
        /// <returns>created MainDashboardViewModel</returns>

        private MainDashboardViewModel CreateDashboardViewModel(Person user)
        {
            var viewModel = new MainDashboardViewModel();

            if (user != null)
            {
                IList <MyProjectViewModel> doneProjects = new List <MyProjectViewModel>();

                viewModel.IsProjectOwnerList = ViewModelListFromProjectModelList(user.AsProjectOwner.Where(p => p.Stage != Stage.Completed).ToList());
                doneProjects = ViewModelListFromProjectModelList(user.AsProjectOwner.Where(p => p.Stage == Stage.Completed).ToList());

                viewModel.IsScrumMasterList = ViewModelListFromProjectModelList(user.AsScrumMaster.Where(p => p.Stage != Stage.Completed).ToList());
                var listTempScrumMaster = ViewModelListFromProjectModelList(user.AsScrumMaster.Where(p => p.Stage == Stage.Completed).ToList());
                foreach (var item in listTempScrumMaster)
                {
                    doneProjects.Add(item);
                }

                IList <Project> InTeamsProjectList = new List <Project>();
                foreach (var item in user.InTeams)
                {
                    InTeamsProjectList.Add(item.Project);
                }

                viewModel.IsInTeamList = ViewModelListFromProjectModelList(InTeamsProjectList.Where(p => p.Stage != Stage.Completed).ToList());
                var listTempInTeam = ViewModelListFromProjectModelList(InTeamsProjectList.Where(p => p.Stage == Stage.Completed).ToList());
                foreach (var item in listTempInTeam)
                {
                    doneProjects.Add(item);
                }

                viewModel.Backlog = new List <ToDoList.Domains.Task>();
                foreach (var project in user.InTeams)
                {
                    var backlogList = project.Project.Tasks.Where(t => t.AssignedTo == null);
                    foreach (var item in backlogList)
                    {
                        viewModel.Backlog.Add(item);
                    }
                }


                viewModel.CompletedList = doneProjects;

                viewModel.AssignedTasksList = user.Tasks.Where(t => t.Status != Status.Done).ToList();

                viewModel.DoneTasksList = user.Tasks.Where(t => t.Status == Status.Done).ToList();

                viewModel.IsProjectOwnerCount = viewModel.IsProjectOwnerList.Count();
                viewModel.IsScrumMasterCount  = viewModel.IsScrumMasterList.Count();
                viewModel.IsInTeamCount       = viewModel.IsInTeamList.Count();
                viewModel.CompletedCount      = viewModel.CompletedList.Count();
                viewModel.AssignedTasksCount  = viewModel.AssignedTasksList.Count();
                viewModel.DoneTasksCount      = viewModel.DoneTasksList.Count();
                viewModel.BacklogCount        = viewModel.Backlog.Count();
            }

            return(viewModel);
        }
Ejemplo n.º 7
0
        public ActionResult Create()
        {
            var householdViewModel = new MainDashboardViewModel();

            if (householdViewModel.Budgets.Count == 0)
            {
                return(RedirectToAction("Create", "Budgets"));
            }
            ViewBag.BudgetId = new SelectList(householdViewModel.Budgets, "Id", "Name");
            return(View());
        }
Ejemplo n.º 8
0
        public IActionResult Index(string sortOrder)
        {
            ViewBag.TitleSortParm = String.IsNullOrEmpty(sortOrder) ? "title_desc" : "";
            ViewBag.StageSortParm = sortOrder == "Stage" ? "stage_desc" : "Stage";
            ViewBag.StartSortParm = sortOrder == "Start" ? "start_desc" : "Start";
            ViewBag.EndSortParm   = sortOrder == "End" ? "end_desc" : "End";

            var projectsList = _projectService.GetAllProjects();

            switch (sortOrder)
            {
            case "title_desc":
                projectsList = projectsList.OrderByDescending(p => p.Title).ToList();
                break;

            case "Start":
                projectsList = projectsList.OrderBy(p => p.StartDate).ToList();
                break;

            case "start_desc":
                projectsList = projectsList.OrderByDescending(p => p.StartDate).ToList();
                break;

            case "End":
                projectsList = projectsList.OrderBy(p => p.EndDate).ToList();
                break;

            case "end_desc":
                projectsList = projectsList.OrderByDescending(p => p.EndDate).ToList();
                break;

            case "Stage":
                projectsList = projectsList.OrderBy(p => p.Stage).ToList();
                break;

            case "stage_desc":
                projectsList = projectsList.OrderByDescending(p => p.Stage).ToList();
                break;

            default:
                projectsList = projectsList.OrderBy(p => p.Title).ToList();
                break;
            }

            var viewModel = new MainDashboardViewModel();

            viewModel.AllProjects = projectsList;

            return(View(viewModel));
            //  return RedirectToAction("List", "Users");
        }
Ejemplo n.º 9
0
        public ActionResult Edit([Bind(Include = "Id,BankAccountId,BudgetItemId,TransactionTypeId,Amount,TransactionDateTime,CreatedById,Memo")] Transaction transaction, string createdById, decimal oldAmount)
        {
            if (ModelState.IsValid)
            {
                var userId = User.Identity.GetUserId();
                if (String.IsNullOrWhiteSpace(userId))
                {
                    return(RedirectToAction("Index", "Households"));
                }

                transaction.BankAccount = _db.BankAccounts.Find(transaction.BankAccountId);
                var currentUserHouseholdId = Helpers.HelperMethods.GetCurrentUserHouseholdId();
                if (currentUserHouseholdId == null ||
                    transaction.BankAccount == null ||
                    transaction.BankAccount.HouseholdId != currentUserHouseholdId)
                {
                    return(RedirectToAction("Index", "Households"));
                }

                //transaction.CreatedById = createdById;
                _db.Entry(transaction).State = EntityState.Modified;
                var ret = _db.SaveChanges();
                if (ret > 0)
                {
                    transaction.TransactionType = _db.TransactionTypes.Find(transaction.TransactionTypeId);

                    int budgetItemId = transaction.BudgetItemId.GetValueOrDefault();
                    transaction.BudgetItem = _db.BudgetItems.Find(budgetItemId);
                    if (transaction.UpdateBalances(isDeleted: false, oldAmount: oldAmount))
                    {
                        _db.Entry(transaction.BankAccount).State = EntityState.Modified;
                        if (transaction.BudgetItem != null)
                        {
                            _db.Entry(transaction.BudgetItem).State = EntityState.Modified;
                        }
                        ret = _db.SaveChanges();
                    }
                }
                return(RedirectToAction("Details", "BankAccounts", new { id = transaction.BankAccount.Id }));
            }

            var householdViewModel = new MainDashboardViewModel();

            ViewBag.BankAccountId     = new SelectList(householdViewModel.BankAccounts, "Id", "Name");
            ViewBag.BudgetItemId      = new SelectList(householdViewModel.BudgetItems, "Id", "Name");
            ViewBag.TransactionTypeId = new SelectList(_db.TransactionTypes, "Id", "Type", transaction.TransactionTypeId);
            return(View(transaction));
        }
Ejemplo n.º 10
0
        public ActionResult Dashboard()
        {
            if (!Request.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }

            MainDashboardViewModel viewModel = new MainDashboardViewModel();

            if (viewModel.Household == null)
            {
                return(RedirectToAction("Index", "Households"));
            }

            return(View(viewModel));
        }
Ejemplo n.º 11
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Transaction transaction = _db.Transactions.Find(id);

            if (transaction == null)
            {
                return(HttpNotFound());
            }
            var householdViewModel = new MainDashboardViewModel();

            ViewBag.BankAccountId     = new SelectList(householdViewModel.BankAccounts, "Id", "Name", transaction.BankAccountId);
            ViewBag.BudgetItemId      = new SelectList(householdViewModel.BudgetItems, "Id", "Name", transaction.BudgetItemId);
            ViewBag.TransactionTypeId = new SelectList(_db.TransactionTypes, "Id", "Type", transaction.TransactionTypeId);
            return(View(transaction));
        }
Ejemplo n.º 12
0
        private void InitialSetup()
        {
            var vm     = new NewSheetWindowViewModel();
            var window = new NewSheetWindow(vm);

            window.Show();

            vm.TimeSheetCreated += (s, ea) =>
            {
                var userInfo = new UserInfo()
                {
                    TimeSheet    = ea.TimeSheet,
                    WorkContract = ea.WorkContract
                };

                //If this step fails, application should crash
                _userRepository.Persist(userInfo);

                var mdvm = new MainDashboardViewModel(userInfo.CalculateSummary(), _userRepository, IoC.Resolve <IWindowService>());
                new MainDashboard(mdvm).Show();

                window.Close();
            };
        }
Ejemplo n.º 13
0
 public ViewTreeCommand(MainDashboardViewModel mainDashboardViewModel)
 {
     _mainDashboardViewModel = mainDashboardViewModel;
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Function for creating Client Dashboard View Model
        /// </summary>
        /// <param name="projectsList">Projects list from Database</param>
        /// <returns>created MainDashboardViewModel</returns>

        private MainDashboardViewModel CreateDashboardViewModel(IList <Project> projectsList)
        {
            var viewModel = new MainDashboardViewModel();

            var viewModelProjects = new List <MyProjectViewModel>();

            foreach (var project in projectsList)
            {
                var viewModelProject = new MyProjectViewModel {
                    Id            = project.Id,
                    Title         = project.Title,
                    Description   = project.Description,
                    ClientCompany = project.ClientCompany,
                    ClientEmail   = project.ClientEmail,
                    StartDate     = project.StartDate,
                    EndDate       = project.EndDate,
                    Stage         = project.Stage,
                    IsPublic      = project.IsPublic
                };

                if (project.ProjectOwner != null)
                {
                    viewModelProject.ProjectOwnerName    = project.ProjectOwner.Name;
                    viewModelProject.ProjectOwnerSurname = project.ProjectOwner.Surname;
                    viewModelProject.ProjectOwnerEmail   = project.ProjectOwner.Email;
                }

                if (project.StartDate != null && project.EndDate != null)
                {
                    TimeSpan durationTime = project.EndDate - project.StartDate;
                    viewModelProject.Duration = (int)durationTime.TotalDays;
                }

                if (project.Tasks.Count() > 0)
                {
                    var done    = project.Tasks.Where(t => t.Status == Status.Done).Count();
                    var total   = project.Tasks.Count();
                    var percent = (double)done / total * 100;
                    viewModelProject.Completeness = (int)percent;
                }

                if (project.EndDate != null)
                {
                    var      dateNow          = DateTime.Now;
                    TimeSpan timeTillDeadline = project.EndDate - dateNow;
                    viewModelProject.TillDeadline = (int)timeTillDeadline.TotalDays;
                }

                viewModelProjects.Add(viewModelProject);
            }

            viewModel.WorkingOnProjectsList   = viewModelProjects.Where(p => p.Stage == Stage.InProgress).ToList();
            viewModel.DoneProjectsList        = viewModelProjects.Where(p => p.Stage == Stage.Completed).ToList();
            viewModel.NewProjectsList         = viewModelProjects.Where(p => p.Stage == Stage.New).ToList();
            viewModel.UnconfirmedProjectsList = viewModelProjects.Where(p => p.Stage == Stage.Unconfirmed).ToList();

            viewModel.WorkingOnProjectsCount   = viewModel.WorkingOnProjectsList.Count();
            viewModel.DoneProjectsCount        = viewModel.DoneProjectsList.Count();
            viewModel.NewProjectsCount         = viewModel.NewProjectsList.Count();
            viewModel.UnconfirmedProjectsCount = viewModel.UnconfirmedProjectsList.Count();

            return(viewModel);
        }
Ejemplo n.º 15
0
        public ActionResult Index()
        {
            MainDashboardViewModel viewModel = new MainDashboardViewModel();

            return(View(viewModel));
        }
Ejemplo n.º 16
0
        public ActionResult MainDashboard()
        {
            MainDashboardViewModel mainDashboard = mainDashboardService.GetMainDashboardModel();

            return(View(mainDashboard));
        }
Ejemplo n.º 17
0
 public ViewLeafCommand(MainDashboardViewModel mainDashboardViewModel)
 {
     _mainDashboardViewModel = mainDashboardViewModel;
 }
 public MainDashboard(MainDashboardViewModel vm)
 {
     InitializeComponent();
     DataContext = vm;
 }