Exemplo n.º 1
0
        public ActionResult Add(MatrixEditModel viewModel)
        {
            if (ModelState.IsValid)
            {
                if (viewModel.Sections != null)
                {
                    foreach (var section in viewModel.Sections)
                    {
                        foreach (var item in section.Items)
                        {
                            item.Testing = ((item.FrontEnd + item.BackEnd) / 100) * viewModel.Settings.Testing;

                            item.ProjectManagement = ((item.FrontEnd + item.BackEnd + item.Design + item.ArtDirector + item.Producer +
                                             item.AccountDirector + item.ServerManagement + item.Seo + item.Copyrighter + item.Testing) / 100) * viewModel.Settings.ProjectManagement;
                        }
                    }
                }

                var domain = Mapper.Map<Matrix>(viewModel);
                domain.CreatedBy = User.Identity.Name;
                domain.CreatedOn = DateTime.UtcNow;

                var id = _matrixService.Add(domain);
                TempData.Add("SuccessMessage", "The new matrix was created successfully");
                return RedirectToAction("Edit", "Matrix", new {id = id});
            }

            return View(viewModel);
        }
Exemplo n.º 2
0
        public ActionResult Add(string id)
        {
            var viewModel = new MatrixEditModel();

            var settings = _settingService.Get();
            viewModel.Settings = Mapper.Map<SettingEditModel>(settings);

            var client = Mapper.Map<ClientViewModel>(_clientService.GetByProjectId(id));
            viewModel.ClientName = client.Name;

            viewModel.ProjectId = id;

            return View(viewModel);
        }
Exemplo n.º 3
0
        public ActionResult Edit(MatrixEditModel viewModel)
        {
            if (ModelState.IsValid)
            {
                if (viewModel.Sections != null)
                {
                    foreach (var section in viewModel.Sections)
                    {
                        foreach (var item in section.Items)
                        {
                            item.Testing = ((item.FrontEnd + item.BackEnd)/100)*viewModel.Settings.Testing;

                            item.ProjectManagement = ((item.FrontEnd + item.BackEnd + item.Design + item.ArtDirector +
                                                       item.Producer +
                                                       item.AccountDirector + item.ServerManagement + item.Seo +
                                                       item.Copyrighter +
                                                       item.Testing)/100)*
                                                     viewModel.Settings.ProjectManagement;
                        }
                    }
                }

                var domain = Mapper.Map(viewModel, _matrixService.GetById(viewModel.MatrixId));
                _matrixService.Edit(domain);
                TempData.Add("SuccessMessage", "The new matrix was updated successfully");
                return RedirectToAction("Edit", "Matrix", new { id = viewModel.MatrixId });
            }

            return View(viewModel);
        }
Exemplo n.º 4
0
        public ActionResult Delete(MatrixEditModel viewModel)
        {
            var clientViewModel = Mapper.Map<ClientViewModel>(_clientService.GetByProjectId(viewModel.ProjectId));

            _matrixService.Delete(viewModel.MatrixId);
            TempData.Add("SuccessMessage", "The matrix " + viewModel.Name + " was deleted successfully");
            return RedirectToAction("Detail", "Client", new { @id = clientViewModel.Id });
        }