public void GetExperts_Should_Fetch_All_Experts()
        {
            var expertService  = new ExpertService(_mockContext.Object);
            var fetchedExperts = expertService.GetExperts();

            Assert.Equal(_testData, fetchedExperts);
        }
Esempio n. 2
0
        public ActionResult ExpertDelete(int id, Expert collection)
        {
            var service = new ExpertService();

            service.Delete(id);
            return(RedirectToAction("GetAllExperts"));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Cost,MaxDaysToComplete,ServiceTypeID,Title,LongDescription,IsPublished,IsOpenForFunding")] ExpertService expertService)
        {
            if (id != expertService.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var user = User.FindFirst(ClaimTypes.NameIdentifier).Value;
                    expertService.ApplicationUserId = user;
                    _context.Update(expertService);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExpertServiceExists(expertService.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(RedirectToAction("Details", new { ID = id }));
            }
            PopulateServiceTypeDropDownList(expertService.ServiceType);
            return(View(expertService));
        }
Esempio n. 4
0
        // GET: Experts/Delete/5
        public ActionResult ExpertDelete(int id)
        {
            var service = new ExpertService();
            var model   = service.Get(id);

            return(View("Experts/Delete", model));
        }
Esempio n. 5
0
        public ActionResult ExpertEdit(int id, DomainModels.Expert model)
        {
            var service = new ExpertService();

            service.UpdateExpert(model);
            return(RedirectToAction("GetAllExperts"));
        }
Esempio n. 6
0
        public ActionResult ExpertCreate(DomainModels.Expert model)
        {
            var service = new ExpertService();
            var result  = service.CreateExpert(model);

            return(RedirectToAction("GetAllExperts"));
        }
Esempio n. 7
0
        public ActionResult GetAllExperts()
        {
            var service = new ExpertService();
            var model   = service.GetAll();

            return(View("Experts/Index", model));
        }
Esempio n. 8
0
 public PredictionsController()
 {
     _context           = new PredictionsContext();
     _expertService     = new ExpertService(_context);
     _tourService       = new TourService(_context);
     _predictionService = new PredictionService(_context);
     _matchService      = new MatchService(_context);
 }
Esempio n. 9
0
 public HomeOfficeController()
 {
     _contactService = new ContactService();
     _companyService = new CompanyService();
     _clientService = new ClientService();
     _expertService = new ExpertService();
     model.ExpertsList = GetExperts;
     model.ClientsList = GetClients;
     //ViewBag.CompanyID = AccountController._compID ;
     clientsAndexperts.Company = _companyService.Find(x => x.CompanyID == AccountController._compID);
 }
        private CurrentSessionOfExpertsService CreateServiceUnderTest()
        {
            _fakeSessionOfExpertsRepository = Substitute.For <ISessionOfExpertsRepository>();
            _fakeSemanticNetworkService     = Substitute.For <SemanticNetworkService>();
            _fakeExpertService = Substitute.For <ExpertService>();

            return(new CurrentSessionOfExpertsService(
                       _fakeSessionOfExpertsRepository,
                       _fakeExpertService,
                       _fakeSemanticNetworkService));
        }
Esempio n. 11
0
        public async Task <IActionResult> Create([Bind("ID,Cost,MaxDaysToComplete,ServiceTypeID,Title,LongDescription,IsPublished")] ExpertService expertService)
        {
            if (ModelState.IsValid)
            {
                var user = User.FindFirst(ClaimTypes.NameIdentifier).Value;
                expertService.ApplicationUserId = user;
                _context.Add(expertService);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            PopulateServiceTypeDropDownList(expertService.ServiceType);
            return(View(expertService));
        }
Esempio n. 12
0
        //private readonly IMapper _mapper;

        public CurrentTournamentToursController(IPredictionsContext context, IMapper mapper)
        {
            _expertService     = new ExpertService(context);
            _tourService       = new TourService(context);
            _predictionService = new PredictionService(context);
            _matchService      = new MatchService(context, mapper);
            _teamService       = new TeamService(context);
            _tournamentService = new TournamentService(context);

            _context = context;

            // _mapper = mapper;

            _fileService = new FileService();
        }
Esempio n. 13
0
        public async Task <IActionResult> CreateDIY([Bind("Invention.Title,Invention.LongDescription,Invention.Valuation,ExpertService.Title,ExpertService.Cost,ExpertService.MaxDaysToComplete")] InventionViewModel inventionCollection)
        {
            //two ways to chain: 1) add a couple or triple of models to a view controller, or 2) just chain them together with adds. Think #2 is better.

            if (ModelState.IsValid)
            {
                var       user      = User.FindFirst(ClaimTypes.NameIdentifier).Value;
                Invention invention = new Invention();
                invention.Title               = Request.Form["Invention.Title"];
                invention.LongDescription     = Request.Form["Invention.LongDescription"];
                invention.Valuation           = Convert.ToInt16(Request.Form["Invention.Valuation"]);
                invention.IsForSale           = false;
                invention.IsOpenForFunding    = true;
                invention.IsPublished         = true;
                invention.ApplicationUserId   = user;
                inventionCollection.Invention = invention;
                inventionCollection.Invention.ApplicationUserId = user;
                ExpertService expertService = new ExpertService();
                expertService.Title             = Request.Form["ExpertService.Title"];
                expertService.IsPublished       = false;
                expertService.LongDescription   = "I will use the funding to work on my invention and to pay for expenses.";
                expertService.MaxDaysToComplete = Convert.ToInt16(Request.Form["ExpertService.MaxDaysToComplete"]);
                expertService.Cost                = Convert.ToInt16(Request.Form["ExpertService.Cost"]);
                expertService.ServiceTypeID       = 2;
                expertService.ApplicationUserId   = user;
                inventionCollection.ExpertService = expertService;
                _context.Add(invention);
                _context.Add(expertService);
                _context.SaveChanges();
                InvestmentRound investmentRound = new InvestmentRound();
                investmentRound.InventionID      = invention.ID;
                investmentRound.RaiseAmount      = expertService.Cost;
                investmentRound.Title            = "DIY Round";
                investmentRound.IsOpenForFunding = true;
                investmentRound.ExpertServiceID  = expertService.ID;
                investmentRound.RoundStatusID    = 1;
                _context.Add(investmentRound);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", new { ID = inventionCollection.Invention.ID }));
            }
            return(View(inventionCollection));
        }
 public ExpertController()
 {
     _expertService = new ExpertService();
 }
Esempio n. 15
0
 public ExpertController()
 {
     _expertService = new ExpertService();
 }
        public new void ProgramParticipantInsert(ProgramParticipant entity)
        {
            ProgramParticipant part = base.ProgramParticipantSelect(entity.ExpertRef, entity.ProgramRef);
              if (part != null)
              {
            return;
              }

              TraceCallEnterEvent.Raise();
              try
              {
            // logical checks:
            ProgramService progSrv = new ProgramService();
            Program selected = progSrv.ProgramSelect(entity.ProgramRef);
            if (selected == null)
              throw new ApplicationException("Ezzel az azonosítóval nem létezik program.");
            if (!selected.IsActive)
              throw new ApplicationException("A program nem aktív.");

            // check permission: Writer or Admin
            string writerRole = selected.OrganisationRef.Value.ToString() + ".Writer";
            PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole);
            PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
            permWriter.Union(permAdmin).Demand();

            ExpertService expSrv = new ExpertService();
            Expert participant = expSrv.ExpertSelect(entity.ExpertRef);
            if (participant == null)
              throw new ApplicationException("Ezzel az azonosítóval nem létezik szakember.");
            if (!participant.IsActive)
              throw new ApplicationException("A szakember nem aktív.");

            // save data:
            base.ProgramParticipantInsert(entity);

            BusinessAuditEvent.Success(
              new EventParameter("ProgramID", entity.ProgramRef.ToString()),
              new EventParameter("ExpertID", entity.ExpertRef.ToString())
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("ProgramID", entity.ProgramRef.ToString()),
              new EventParameter("ExpertID", entity.ExpertRef.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Esempio n. 17
0
        /// <summary>
        /// Exports to CSV2.
        /// </summary>
        /// <param name="dt">The dt.</param>
        /// <param name="publicityLevel">The publicity level.</param>
        /// <param name="ownOrgId">The own org id.</param>
        /// <returns></returns>
        private static string CreateCsvFromPrograms(DataTable dt, int publicityLevel, Guid ownOrgId)
        {
            string EndOfLine = "\n";
              string separator = ";";
              string separator5 = ";;;;;";
              StringBuilder rtfString = new StringBuilder();

              // Build csv header row
              rtfString.Append("Program neve;");
              rtfString.Append("Program típusa;");
              rtfString.Append("Szervezet;");
              rtfString.Append("Felelõs;");
              rtfString.Append("Koordinátor1;");
              rtfString.Append("Koordinátor2;");
              rtfString.Append("Program státusza;");
              rtfString.Append("Program kezdete;");
              rtfString.Append("Program vége;");
              rtfString.Append("A program részletes leírása;");

              rtfString.Append("Résztvevõ szakember neve;");
              rtfString.Append("E-mail cím;");
              rtfString.Append("Cím;");
              rtfString.Append("Telefonszám;");
              rtfString.Append("Partner szervezet neve;");
              rtfString.Append("Címe;");
              rtfString.Append("Honlap;");
              rtfString.Append("Megye;");
              rtfString.Append("Szervezeti forma;");
              rtfString.Append("Csatolt dokumentum neve;");
              rtfString.Append("Fájlnév;");
              rtfString.Append("Dátum;");
              rtfString.Append("Fájlméret;\n");

              foreach (DataRow dr in dt.Rows)
              {
            Guid progId = new Guid(dr["uID"].ToString());
            //Program prg = (Program)doc;
            StringBuilder line = new StringBuilder();
            int maxCount = 0; //letároljuk a maximális elemszámot -> ennyi sora lesz az adott programnak

            ExpertService srvExpert = new ExpertService();
            //Expert responsible = srvExpert.ExpertSelect(prg.ResponsibleRef);
            //Expert coordinator1 = srvExpert.ExpertSelect(prg.Coordinator1Ref);
            //Expert coordinator2 = srvExpert.ExpertSelect(prg.Coordinator1Ref);

            //elsõ sor összeállítása
            line.Append(Helper.CsvCheck(dr["cName"].ToString()));
            line.Append(separator);
            line.Append(Helper.CsvCheck(dr["cProgramCategory"].ToString()));
            line.Append(separator);
            line.Append(Helper.CsvCheck(dr["cOrganisationName"].ToString()));
            line.Append(separator);
            line.Append(Helper.CsvCheck(dr["cResponsibleName"].ToString()));
            line.Append(separator);
            line.Append(Helper.CsvCheck(dr["cCoord1Name"].ToString()));
            line.Append(separator);
            line.Append(Helper.CsvCheck(dr["cCoord2Name"].ToString()));
            line.Append(separator);
            line.Append(Helper.CsvCheck(dr["cProgramStatus"].ToString()));
            line.Append(separator);
            line.Append(Helper.CsvCheck(dr["cStartDate"].ToString()));
            line.Append(separator);
            line.Append(Helper.CsvCheck(dr["cFinishDate"].ToString()));
            line.Append(separator);
            line.Append(Helper.CsvCheck(dr["cDescription"].ToString()));
            line.Append(separator);

            #region Résztvevõ szakemberek lekérdezése

            ExpertDispsetContainer contExpert = srvExpert.ExpertSelectParticipantsOfProgram(progId);

            if (contExpert.AllCount > maxCount) maxCount = contExpert.AllCount;

            if (contExpert.AllCount > 0)
            {
              ExpertDispset firstExpert = (ExpertDispset) contExpert.All.Items[0];
              line.Append(Helper.CsvCheck(firstExpert.Name));
              line.Append(separator);
              if (publicityLevel != 0)
              {
            line.Append(Helper.CsvCheck(firstExpert.Email1 + " " + firstExpert.Email2 + " " + firstExpert.Email3));
            line.Append(separator);
              }
              else
              {
            line.Append(separator);
              }
              line.Append(Helper.CsvCheck(firstExpert.Address));
              line.Append(separator);
              line.Append(Helper.CsvCheck(firstExpert.Phone1 + " " + firstExpert.Phone2 + " " + firstExpert.Phone3));
              line.Append(separator);
            }
            else
            {
              line.Append(separator);
              line.Append(separator);
              line.Append(separator);
              line.Append(separator);
            }

            #endregion

            #region Partner szervezetek lekérdezése

            OrganisationService srvOrg = new OrganisationService();
            OrganisationDispsetContainer contDispOrg = srvOrg.OrganisationSelectPartnersOfProgram(progId);

            if (contDispOrg.AllCount > maxCount) maxCount = contDispOrg.AllCount;

            if (contDispOrg.AllCount > 0)
            {
              OrganisationDispset firstDispOrg = (OrganisationDispset) contDispOrg.All.Items[0];
              line.Append(Helper.CsvCheck(firstDispOrg.Name));
              line.Append(separator);
              line.Append(Helper.CsvCheck(firstDispOrg.Address));
              line.Append(separator);
              line.Append(Helper.CsvCheck(firstDispOrg.HomePage));
              line.Append(separator);

              RegionService srvRegion = new RegionService();
              line.Append(Helper.CsvCheck(srvRegion.RegionSelect(firstDispOrg.RegionRef).Name));
              line.Append(separator);

              OrganisationFormService srvOrgForm = new OrganisationFormService();
              line.Append(Helper.CsvCheck(srvOrgForm.OrganisationFormSelect(firstDispOrg.OrganisationFormRef).Name));
              line.Append(separator);
            }
            else
            {
              line.Append(separator);
              line.Append(separator);
              line.Append(separator);
              line.Append(separator);
              line.Append(separator);
            }

            #endregion

            #region Csatolt dokumentumok lekérdezése

            ProgramAttachmentService srvProgAttach = new ProgramAttachmentService();
            ProgramAttachmentDispsetContainer contDispProgAttach =
              srvProgAttach.ProgramAttachmentSelectAttachmentsOfProgram(progId);

            if (contDispProgAttach.AllCount > maxCount) maxCount = contDispProgAttach.AllCount;

            if (contDispProgAttach.AllCount > 0)
            {
              ProgramAttachmentDispset firstDispProgAttach = (ProgramAttachmentDispset) contDispProgAttach.All.Items[0];

              line.Append(Helper.CsvCheck(firstDispProgAttach.Name.ToString()));
              line.Append(separator);
              line.Append(Helper.CsvCheck(firstDispProgAttach.Path.ToString()));
              line.Append(separator);
              line.Append(Helper.CsvCheck(firstDispProgAttach.CreatedDate.ToString()));
              line.Append(separator);
              line.Append(Helper.CsvCheck(firstDispProgAttach.FileSize.ToString()));
              line.Append(separator);
            }
            else
            {
              line.Append(separator);
              line.Append(separator);
              line.Append(separator);
              line.Append(separator);
            }

            #endregion

            #region Kérdõívek lekérdezése (kérdések/válaszok)

            //ITemplateService srvTemplate = ServiceFactory.GetTemplateService();
            TemplateContainer contTemplate = null;

            #endregion

            rtfString.Append(line);
            rtfString.Append(EndOfLine);
            line = new StringBuilder(); //új sor

            bool IsBinate = false;

            //többi sor
            for (int i = 1; i < maxCount; i++)
            {
              //ha nincs kérdõív akkor kiugrunk
              if ((maxCount == 1) && (contTemplate.AllCount == 0))
              {
            rtfString.Append(line);
            rtfString.Append(EndOfLine);
            break;
              }

              IsBinate = !IsBinate;
              line.Append(separator5);
              line.Append(separator5);

              #region a többi résztvevõ szakember hozzáadása

              if (contExpert.AllCount > i)
              {
            ExpertDispset firstExpert = (ExpertDispset) contExpert.All.Items[i];
            line.Append(Helper.CsvCheck(firstExpert.Name));
            line.Append(separator);
            if (publicityLevel != 0)
            {
              line.Append(Helper.CsvCheck(firstExpert.Email1 + " " + firstExpert.Email2 + " " + firstExpert.Email3));
              line.Append(separator);
            }
            else
            {
              line.Append(separator);
            }

            line.Append(Helper.CsvCheck(firstExpert.Address));
            line.Append(separator);
            line.Append(Helper.CsvCheck(firstExpert.Phone1 + " " + firstExpert.Phone2 + " " + firstExpert.Phone3));
            line.Append(separator);
              }
              else
              {
            line.Append(separator);
            line.Append(separator);
            line.Append(separator);
            line.Append(separator);
              }

              #endregion

              #region a többi partner szervezetek lekérdezése

              if (contDispOrg.AllCount > i)
              {
            OrganisationDispset firstDispOrg = (OrganisationDispset) contDispOrg.All.Items[i];
            line.Append(Helper.CsvCheck(firstDispOrg.Name));
            line.Append(separator);
            line.Append(Helper.CsvCheck(firstDispOrg.Address));
            line.Append(separator);
            line.Append(Helper.CsvCheck(firstDispOrg.HomePage));
            line.Append(separator);

            IRegionService srvRegion = new RegionService();

            if (!firstDispOrg.RegionRef.IsNull)
            {
              line.Append(Helper.CsvCheck(srvRegion.RegionSelect(firstDispOrg.RegionRef).Name));
              line.Append(separator);
            }

            IOrganisationFormService srvOrgForm = new OrganisationFormService();
            line.Append(Helper.CsvCheck(srvOrgForm.OrganisationFormSelect(firstDispOrg.OrganisationFormRef).Name));
            line.Append(separator);
              }
              else
              {
            line.Append(separator5);
              }

              #endregion

              #region a többi csatolt dokumentumok lekérdezése

              if (contDispProgAttach.AllCount > i)
              {
            ProgramAttachmentDispset firstDispProgAttach = (ProgramAttachmentDispset) contDispProgAttach.All.Items[i];

            line.Append(Helper.CsvCheck(firstDispProgAttach.Name.ToString()));
            line.Append(separator);
            line.Append(Helper.CsvCheck(firstDispProgAttach.Path.ToString()));
            line.Append(separator);
            line.Append(Helper.CsvCheck(firstDispProgAttach.CreatedDate.ToString()));
            line.Append(separator);
            line.Append(Helper.CsvCheck(firstDispProgAttach.FileSize.ToString()));
            line.Append(separator);
              }
              else
              {
            line.Append(separator);
            line.Append(separator);
            line.Append(separator);
            line.Append(separator);
              }

              #endregion

              #region Kérdõívek válaszok hozzáadása

              #endregion

              rtfString.Append(line);
              rtfString.Append(EndOfLine);
              line = new StringBuilder(); //új sor
            }
              }

              return rtfString.ToString();
        }
Esempio n. 18
0
        public void ProgramResponsibleUpdate(Program entity)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            // logical checks:
            Program selected = base.ProgramSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("Ezzel az azonosítóval nem létezik program.");
            if (!selected.IsActive)
              throw new ApplicationException("A program nem aktív.");

            // check permission: Writer or Admin
            string writerRole = selected.OrganisationRef.Value.ToString() + ".Writer";
            PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole);
            PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
            permWriter.Union(permAdmin).Demand();

            if (!entity.ResponsibleRef.IsNull)
            {
              ExpertService expSrv = new ExpertService();
              Expert responsible = expSrv.ExpertSelect(entity.ResponsibleRef);
              if (responsible == null)
            throw new ApplicationException("Ezzel az azonosítóval nem létezik szakember.");
              if (!responsible.IsActive)
            throw new ApplicationException("A szakember nem aktív.");
            }

            // save data:
            selected.ResponsibleRef = entity.ResponsibleRef;
            selected.LastModifiedDate = DateTime.Now;
            base.ProgramUpdate(selected);

            BusinessAuditEvent.Success(
              new EventParameter("ProgramID", entity.ID.ToString()),
              new EventParameter("ProgramName", selected.Name),
              new EventParameter("ResponsibleID", entity.ResponsibleRef.ToString())
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("ProgramID", entity.ID.ToString()),
              new EventParameter("ResponsibleID", entity.ResponsibleRef.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }