public List <Internship> GetAllInternships()
        {
            List <Internship> internshipList = new List <Internship>();

            var data = (from iship in _context.Internships.Find(_ => true).ToEnumerable()
                        select new
            {
                iship.Id,
                iship.InternshipName
            }).ToList();

            data.ForEach(x =>
            {
                Internship obj     = new Internship();
                obj.Id             = x.Id;
                obj.InternshipName = x.InternshipName;
                internshipList.Add(obj);
            });

            return(internshipList);
        }
        public ActionResult <Internship> PostInternship(InternshipModel newInternship)
        {
            try
            {
                var id = _customAuthManager.Tokens.FirstOrDefault().Value.Item3;

                // ToDO-> get User ID from Session
                User       user       = _context.Users.Find(id);
                Internship internship = new Internship();
                // SetAddorUpdateIntern(Intership - TYPE, User =TYPE, Bool -TYPE)
                // the above method fill the object with user provided values and bool if it is for update
                internship.SetAddorUpdateIntern(newInternship, user);
                _context.Internships.Add(internship);
                _context.SaveChanges();
                return(Ok(internship));
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }
Exemple #3
0
        public ActionResult Create(Internship intern)
        {
            try
            {
                // ToDO-> get User ID from Session
                // geting menual user
                User       user       = _context.Users.Find(2);
                Internship internship = new Internship();
                // SetAddorUpdateIntern(Intership - TYPE, User =TYPE, Bool -TYPE)
                // the above method fill the object with user provided values and bool if it is for update
                internship.SetAddorUpdateIntern(intern, user);
                _context.Internships.Add(internship);
                _context.SaveChanges();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
        public DataResponseHandler <string> AddEntity(Internship newItem)
        {
            using (var context = new Entities())
            {
                try
                {
                    var role = new DataResponseHandler <string> {
                        Succes = true
                    };
                    context.Internships.Add(newItem);
                    role.Container = newItem.InternshipId;

                    return(role);
                }
                catch (Exception ex)
                {
                    return(new DataResponseHandler <string> {
                        Succes = false, Container = ex.Message
                    });
                }
            }
        }
        private void updateCompanyButton_Click(object sender, EventArgs e)
        {
            addInternshipButton.Visible = false;
            updateCompanyButton.Visible = false;

            companyCityTextBox.ReadOnly        = true;
            companyDescriptionTextBox.ReadOnly = true;
            companyEmailTextBox.ReadOnly       = true;
            companyIsPaidTextBox.ReadOnly      = true;
            companyPositionTextBox.ReadOnly    = true;
            companyNameTextBox.ReadOnly        = true;


            foreach (Internship internshipFromList in internshipList)
            {
                if (internshipListBox.SelectedItem.ToString() == internshipFromList.Company)
                {
                    Internship newInternship = new Internship();
                    newInternship = internshipFromList;

                    newInternship.City        = companyCityTextBox.Text;
                    newInternship.Company     = companyNameTextBox.Text;
                    newInternship.Position    = companyPositionTextBox.Text;
                    newInternship.Paid        = companyIsPaidTextBox.Text;
                    newInternship.Email       = companyEmailTextBox.Text;
                    newInternship.Description = companyDescriptionTextBox.Text;

                    service.UpdateCurrentInternship(internshipFromList.Id, newInternship);
                    MessageBox.Show("Internship modified!");
                }
            }
            user = service.Login(user.Email, user.Password);

            this.Close();
            InternshipViewForm internshipViewForm = new InternshipViewForm(user);

            internshipViewForm.Show();
        }
        // GET: Internships/Edit/5
        public async System.Threading.Tasks.Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Internship internship = context.Internships.Find(id);

            if (internship == null)
            {
                return(HttpNotFound());
            }
            var currentUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            var user    = context.Users.First(x => x.Id == currentUser.Id);
            var input   = user.UserName;
            var pattern = @"@";

            String[] elements = Regex.Split(input, pattern);
            ViewBag.FirmId = new SelectList(context.Firms, "FirmId", "FirmName")
                             .Where(i => i.Text == elements[0]);
            return(View(internship));
        }
        public IActionResult InternshipApply(int?id, ApplyInternship fromData)
        {
            // the User is student

            // Make changes to AppliedInternship table.
            // make nortfication.
            try
            {
                using (GlobalDBContext _context = new GlobalDBContext())
                {
                    Internship        intern     = _context.Internships.Find(id);
                    User              user       = _context.Users.Find(_customAuthManager.Tokens.FirstOrDefault().Value.Item3);
                    AppliedInternship APP_Intern = new AppliedInternship(user, intern);
                    _context.AppliedInternships.Add(APP_Intern);
                    _context.SaveChanges();
                    return(View());
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public IActionResult Index()
        {
            // Display User name on the right-top corner - shows user is logedIN
            ViewData["LoggeduserName"] = _user.UserFirstName + ' ' + _user.UserLastName;

            // Geting Dashboard Menu from project/data/DashboardMenuOption.json into ViewData
            string path = _env.ContentRootPath + @"\Data\DashboardMenuOptions.json";

            ViewData["menuItems"] = HelpersFunctions.GetMenuOptionsForUser(_user.UserId, path);

            using (GlobalDBContext _context = new GlobalDBContext())
            {
                // Geting internshps student applied for using his/her userID
                var appliedInterns        = _context.AppliedInternships.Include(i => i.Internship).Where(e => e.User == _user).ToList();
                List <Internship> interns = new List <Internship>();
                foreach (var appliedIntern in appliedInterns)
                {
                    Internship theIntern = appliedIntern.Internship;
                    interns.Add(theIntern);
                }
            }
            return(View());
        }
Exemple #9
0
        public Internship AddInternship(Internship internship)
        {
            using (UnitOfWork uow = new UnitOfWork())
            {
                var company = uow.CompanyRepository.getDbSet()
                              .Where(c => c.Id == internship.CompanyId)
                              .Include(c => c.Subscriptions)
                              .FirstOrDefault();

                if (company == null)
                {
                    throw new Exception($"Compania cu id-ul {internship.Id} nu exista");
                }
                uow.InternshipRepository.AddEntity(internship);
                uow.Save();

                var usersEmails = new List <string>();

                foreach (var subscription in company.Subscriptions)
                {
                    var student = uow.StudentRepository.GetById(subscription.StudentId);
                    var user    = _userManager.FindByIdAsync(student.IdUser).Result;
                    usersEmails.Add(user.Email);
                }

                Task emailSenderTask = new Task(new Action(() =>
                {
                    var emailSender = new EmailSender();
                    string subject  = "New internship!";
                    string message  = "A new internship has been added for " + company.Name + "! Check more about it here: http://localhost:8080/";
                    emailSender.SendEmailsAsync(usersEmails, subject, message);
                }));
                emailSenderTask.Start();

                return(internship);
            }
        }
Exemple #10
0
        private void btnModify_Click(object sender, EventArgs e)
        {
            Employee emp      = null;
            string   ccode    = "";
            int      temp_seq = 0;

            try
            {
                if (cmbCategory.Text == "FullTime")
                {
                    ccode = "FT";
                    if (!DataValidator.verifyData(txtFTAnnualSalary.Text, new Regex(DataValidator.patternMoney)))
                    {
                        MessageBox.Show("Annual Salary must be a numeric value", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    emp = new FullTime((EnumPosition)cmbFTPosition.SelectedItem,
                                       Convert.ToDouble(txtFTAnnualSalary.Text));
                    temp_seq = emp.getId(); //Store last sequence
                }
                else if (cmbCategory.Text == "PartTime")
                {
                    ccode = "PT-";
                    if (cmbPTContractType.Text == "Consultant_Trainers")
                    {
                        ccode += "CON";
                        if (!DataValidator.verifyData(txtPTContractMonth.Text, new Regex(DataValidator.patternNumber)))
                        {
                            MessageBox.Show("Contract Month must be a number", "Error",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        if (!DataValidator.verifyData(txtPTTCHourlySal.Text, new Regex(DataValidator.patternHours)))
                        {
                            MessageBox.Show("Week hours must be a numeric value", "Error",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        if (!DataValidator.verifyData(txtPTCTWeekHours.Text, new Regex(DataValidator.patternHours)))
                        {
                            MessageBox.Show("Hours must be a numeric value", "Error",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        emp = new ConsultantTrainer((EnumContractType)cmbPTContractType.SelectedItem,
                                                    Convert.ToInt16(txtPTContractMonth.Text),
                                                    Convert.ToDouble(txtPTTCHourlySal.Text),
                                                    Convert.ToDouble(txtPTCTWeekHours.Text));
                        temp_seq = emp.getId(); //Store last sequence
                    }
                    else if (cmbPTContractType.Text == "Internship_Student")
                    {
                        ccode += "INT";
                        if (!DataValidator.verifyData(txtPTInternSal.Text, new Regex(DataValidator.patternMoney)))
                        {
                            MessageBox.Show("Internship Salary must be a numeric value", "Error",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        emp = new Internship(Convert.ToDouble(txtPTInternSal.Text),
                                             (EnumContractType)cmbPTContractType.SelectedItem,
                                             Convert.ToInt16(txtPTContractMonth.Text));
                        temp_seq = emp.getId(); //Store last sequence
                    }
                    else
                    {
                        MessageBox.Show("Must be selected a Contract Type...", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Must be selected an Employee's Category...", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                try
                {
                    emp.setFname(txtFirstName.Text);
                    emp.setLname(txtLastName.Text);
                    if (!DataValidator.verifyData(txtSIN.Text, new Regex(DataValidator.patternSIN)))
                    {
                        MessageBox.Show("Social Security must be a code like this ###-###-###", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    emp.setDepartment((EnumDepartment)cmbDept.SelectedItem);
                    emp.setCategory((EnumCategory)cmbCategory.SelectedItem);
                    if (!DataValidator.verifyData(txtHDay.Text, new Regex(DataValidator.patternDay)))
                    {
                        MessageBox.Show("Wrong day...Must be between 1 and 31", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    if (!DataValidator.verifyData(txtHMonth.Text, new Regex(DataValidator.patternMonth)))
                    {
                        MessageBox.Show("Wrong month...Must be between 1 and 12", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    if (!DataValidator.verifyData(txtHYear.Text, new Regex(DataValidator.patternYear)))
                    {
                        MessageBox.Show("Wrong year...Must be between 1900 and 2099", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    emp.setHire_date(new Date(txtHDay.Text, txtHMonth.Text, txtHYear.Text));
                    if (!DataValidator.verifyData(txtBDay.Text, new Regex(DataValidator.patternDay)))
                    {
                        MessageBox.Show("Wrong day...Must be between 1 and 31", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    if (!DataValidator.verifyData(txtBMonth.Text, new Regex(DataValidator.patternMonth)))
                    {
                        MessageBox.Show("Wrong month...Must be between 1 and 12", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    if (!DataValidator.verifyData(txtBYear.Text, new Regex(DataValidator.patternYear)))
                    {
                        MessageBox.Show("Wrong year...Must be between 1900 and 2099", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    emp.setBirthday(new Date(txtBDay.Text, txtBMonth.Text, txtBYear.Text));

                    if (!DataValidator.verifyData(txtAddStrNo.Text, new Regex(DataValidator.patternNumber)))
                    {
                        MessageBox.Show("Wrong Street No... Must be a number", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    if (!DataValidator.verifyData(txtAddApt.Text, new Regex(DataValidator.patternApt)))
                    {
                        MessageBox.Show("Wrong Appartment/House No... Must be a number", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    if (!DataValidator.verifyData(txtAddApt.Text, new Regex(DataValidator.patternApt)))
                    {
                        MessageBox.Show("Wrong Zip Code... Must be like this X#X-#X#", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    emp.setAddress(new Address(txtAddStrNo.Text, txtAddStrName.Text,
                                               txtAddApt.Text, txtAddCity.Text, txtAddState.Text,
                                               txtAddCountry.Text, txtAddZipCode.Text));

                    if (!DataValidator.verifyData(txtHCountCode.Text, new Regex(DataValidator.patternCountcode)))
                    {
                        MessageBox.Show("Wrong Phone Country Code", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    if (!DataValidator.verifyData(txtHCityCode.Text, new Regex(DataValidator.patternCitycode)))
                    {
                        MessageBox.Show("Wrong Phone City Code...Must be a 3 digits number", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    if (!DataValidator.verifyData(txtHLocalCode.Text, new Regex(DataValidator.patternLocalcode)))
                    {
                        MessageBox.Show("Wrong Phone Local...Must be a 7 digits number", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    emp.setHome_ph(new Phone(txtHCountCode.Text, txtHCityCode.Text,
                                             txtHLocalCode.Text));

                    if (!DataValidator.verifyData(txtCCountCode.Text, new Regex(DataValidator.patternCountcode)))
                    {
                        MessageBox.Show("Wrong Phone Country Code", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    if (!DataValidator.verifyData(txtCCityCode.Text, new Regex(DataValidator.patternCitycode)))
                    {
                        MessageBox.Show("Wrong Phone City Code...Must be a 3 digits number", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    if (!DataValidator.verifyData(txtCLocalCode.Text, new Regex(DataValidator.patternLocalcode)))
                    {
                        MessageBox.Show("Wrong Phone Local...Must be a 7 digits number", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    emp.setCel_ph(new Phone(txtCCountCode.Text, txtCCityCode.Text,
                                            txtCLocalCode.Text));

                    if (!DataValidator.verifyData(txtEmail.Text, new Regex(DataValidator.patternEmail)))
                    {
                        MessageBox.Show("Wrong email address", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        SequenceID.setEmployee_id(temp_seq); // Decrease the sequence
                        return;
                    }
                    emp.setEmail(txtEmail.Text);
                    emp.setSocial_security(tempsin); //Assign last displayed SIN
                    txtTwoWeeksSal.Text = emp.getTwoWeeks_salary().ToString("#.##") + " $";

                    emp.setId(temp_id);
                    emp.setContract(ccode);
                    txtKey.Text = emp.getContract();

                    if (txtSIN.Text != emp.getSocial_security())
                    {
                        MessageBox.Show("Can't to modify the SIN in the Modify option.  It should use Add button",
                                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (update_index > -1)
                    {
                        // Update list Box and list of employees
                        //listBoxEmployees.Items.Insert(update_index, emp);
                        employees.modify(emp, emp.getSocial_security());
                        listBoxEmployees.Items.Clear();
                        foreach (Employee temp in employees.ReturnList())
                        {
                            this.listBoxEmployees.Items.Add(employees.ShowListInBox(temp));
                        }

                        btnReset.PerformClick();

                        update_index = -1;

                        save_flag = true;

                        MessageBox.Show("Employee Mofified", "Confirmation",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("It must to select an item and display it.  Use Display Option",
                                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch
                {
                    MessageBox.Show("Missing or incorrects values to enter...Check and Try again",
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch
            {
                MessageBox.Show("2222222222222Missing or incorrects values to enter...Check and Try again",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #11
0
 public async Task UpdateInternship(Internship internship)
 {
     _context.Internships.Update(internship);
     await _context.SaveChangesAsync();
 }
        public async Task <IActionResult> CreateDiary(string id, string companyId, List <InternshipTask> tasks)
        {
            var student = await context.Students
                          .Include(x => x.Internships)
                          .SingleAsync(x => x.Id == id);

            var diary = new Diary
            {
                Id          = Guid.NewGuid(),
                Student     = student,
                Internships = student.Internships.Where(x => x.IsActive).ToList(),
            };
            var internship = new Internship()
            {
                Student   = student,
                StudentId = student.Id,
                IsActive  = true,
                Diary     = diary,
                DiaryId   = diary.Id,
                CompanyId = Guid.Parse(companyId)
            };

            foreach (var studentInternship in student.Internships)
            {
                studentInternship.IsActive = false;
            }

            student.Internships.Add(internship);

            HttpClient httpClient = new HttpClient();

            httpClient.BaseAddress = new Uri("http://12cfc75fc22c.ngrok.io/");
            foreach (var task in tasks)
            {
                task.Id      = Guid.NewGuid();
                task.DiaryId = diary.Id;
                task.Id      = Guid.NewGuid();
                task.DiaryId = diary.Id;
                var response = httpClient.GetAsync($"/predict/{task.InternshipTaskName}").Result;
                if (!response.IsSuccessStatusCode)
                {
                    continue;
                }
                var res        = response.Content.ReadAsStringAsync().Result;
                var prediction = JsonConvert.DeserializeObject <Prediction>(res);
                prediction.TaskId = task.Id;
                context.Add(prediction);
                task.Prediction = prediction;
            }

            await context.AddRangeAsync(tasks);

            await context.AddAsync(diary);

            await context.AddAsync(internship);

            context.Update(student);
            await context.SaveChangesAsync();

            return(Ok(diary.Id));
        }
 public bool Update(Internship internship)
 {
     _intershipRepository.Add(internship);
     return(true);
 }
Exemple #14
0
        public void UserServiceTest_getAll()
        {
            // Arrange
            var repo = new ScientificReportData.Models.Report
            {
                Id             = 1,
                Date           = new DateTime(1999, 12, 1),
                DepartmentWork = "AMI",
                Conferences    = "none",
                Contetnt       = "smth",
                Intro          = "Begin"
            };
            List <Report> reports = new List <Report>();

            reports.Add(repo);

            List <Author> authors = new List <Author>();
            var           author  = new Author
            {
                Name = "Bogdan",
                Id   = 1,
            };

            authors.Add(author);

            var publication = new Publication
            {
                Status  = "prove",
                Authors = authors,
                Id      = 1,
                Date    = new DateTime(2009, 12, 1),
                Topic   = "sfs",
                Type    = "math"
            };
            List <Publication> publications = new List <Publication>();

            publications.Add(publication);

            var internship = new Internship
            {
                Name = "mine",
                Id   = 1
            };

            List <Internship> internships = new List <Internship>();

            internships.Add(internship);

            var user = new ScientificReportData.Models.User
            {
                Name           = "ME",
                Birthdate      = new DateTime(1992, 1, 12),
                DegreeLevel    = "BACHELOR",
                DegreeDate     = new DateTime(2010, 1, 12),
                GraduationDate = new DateTime(2011, 1, 12),
                Title          = "124rs",
                TitleDate      = new DateTime(2016, 1, 12),
                Faculty        = "AMI",
                Department     = "AM",
                IsAdmin        = false,
                IsApproved     = true,
                Reports        = reports,
                Publications   = publications,
                Internships    = internships,
            };
            var testList = new List <User>()
            {
                user
            };

            var dbSetMock = new Mock <DbSet <User> >();

            dbSetMock.As <IQueryable <User> >().Setup(x => x.Provider).Returns(testList.AsQueryable().Provider);
            dbSetMock.As <IQueryable <User> >().Setup(x => x.Expression).Returns(testList.AsQueryable().Expression);
            dbSetMock.As <IQueryable <User> >().Setup(x => x.ElementType).Returns(testList.AsQueryable().ElementType);
            dbSetMock.As <IQueryable <User> >().Setup(x => x.GetEnumerator()).Returns(testList.AsQueryable().GetEnumerator());

            var context = new Mock <DbContext>();

            context.Setup(x => x.Set <User>()).Returns(dbSetMock.Object);

            // Act
            var repository = new Repository <User, string>(context.Object);
            var result     = repository.GetAll();

            // Assert
            Assert.AreEqual(testList, result.ToList());
        }
Exemple #15
0
 public static InternshipModel InternshipToInternshipModel(Internship value)
 {
     return(new InternshipModel {
         Id = value.Id, Name = value.Name, Year = value.Year
     });
 }
Exemple #16
0
 public async Task CreateInternship(Internship internship)
 {
     _context.Internships.Add(internship);
     await _context.SaveChangesAsync();
 }
        // GET: Announcment
        public ActionResult Index()
        {
            Internship internship = entities.Internships.FirstOrDefault();

            return(View(internship));
        }
        public async Task <ActionResult> Create(FormCollection collection)
        {
            if (Session["user_type"].Equals("GST") || Session["user_type"].Equals("STD"))
            {
                return(RedirectToAction("../Home/Index"));
            }

            bool             flag = false;
            InternshipRegErr err  = new InternshipRegErr();

            ViewBag.Categories = db.CategoriesLists;
            ViewBag.Locations  = db.LocationsLists;
            ViewBag.Perks      = db.PerksLists;
            ViewBag.Skills     = db.SkillsLists;

            Internship i = new Internship();

            i.About          = Request.Form["about"];
            i.ContactEmail   = Request.Form["contactemail"];
            i.ContactMobile  = Request.Form["contactmobile"];
            i.C_Id           = Session["user_id"].ToString();
            i.InternshipType = Request.Form["type"];

            DateTime result;

            if (string.IsNullOrWhiteSpace(i.About))
            {
                flag      = true;
                err.About = "You must write details about the internship";
            }

            if (!string.IsNullOrWhiteSpace(Request.Form["startdate"]))
            {
                if (DateTime.TryParse(Request.Form["startdate"], out result))
                {
                    i.StartDate = Convert.ToDateTime(Request.Form["startdate"]);
                }
                else
                {
                    flag          = true;
                    err.StartDate = "Start date not in proper format";
                }
            }

            int value;

            if (string.IsNullOrWhiteSpace(Request.Form["minduration"]) || !Int32.TryParse(Request.Form["minduration"], out value))
            {
                flag            = true;
                err.MinDuration = "Minimum Duration cannot be Empty";
            }
            else
            {
                i.MinDuration = Convert.ToInt32(Request.Form["minduration"]);
                if (i.MinDuration <= 0)
                {
                    flag            = true;
                    err.MinDuration = "Minimum Duration should be atleast 1 month";
                }
            }

            if (string.IsNullOrWhiteSpace(Request.Form["maxduration"]) || !Int32.TryParse(Request.Form["maxduration"], out value))
            {
                flag            = true;
                err.MaxDuration = "Maximum Dauration cannot be Empty";
            }
            else
            {
                i.MaxDuration = Convert.ToInt32(Request.Form["maxduration"]);
                if (i.MaxDuration <= 0)
                {
                    flag            = true;
                    err.MaxDuration = "Maximum Duration should be atleast 1 month";
                }
            }

            if (string.IsNullOrWhiteSpace(Request.Form["seats"]) || !Int32.TryParse(Request.Form["seats"], out value))
            {
                flag = true;
                err.AvailableSeats = "Cannot be empty";
            }
            else
            {
                i.AvailableSeats = Convert.ToInt32(Request.Form["seats"]);
                if (i.AvailableSeats <= 0)
                {
                    flag = true;
                    err.AvailableSeats = "Value should be atleast 1 seat";
                }
            }

            if (string.IsNullOrWhiteSpace(Request.Form["applybefore"]) || !DateTime.TryParse(Request.Form["applybefore"], out result))
            {
                flag            = true;
                err.ApplyBefore = "Apply Before Date cannot be Empty";
            }
            else
            {
                i.ApplyBefore = Convert.ToDateTime(Request.Form["applybefore"]);
            }

            if (string.IsNullOrWhiteSpace(i.ContactEmail) || !Regex.IsMatch(i.ContactEmail, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase))
            {
                flag             = true;
                err.ContactEmail = "Email Cannot be empty. It should be a valid email address.";
            }

            if (!string.IsNullOrWhiteSpace(Request.Form["contactmobile"]))
            {
                i.ContactMobile = Request.Form["contactmobile"];
            }

            if (!string.IsNullOrWhiteSpace(Request.Form["locations"]))
            {
                foreach (string s in Request.Form["locations"].Split(','))
                {
                    InternshipLocation templ = new InternshipLocation();
                    templ.L_Id = Convert.ToInt32(s);
                    i.InternshipLocations.Add(templ);
                }
            }
            else
            {
                flag          = true;
                err.Locations = "You should select atleast one location";
            }

            if (!string.IsNullOrWhiteSpace(Request.Form["skills"]))
            {
                foreach (string s in Request.Form["skills"].Split(','))
                {
                    InternshipSkill temps = new InternshipSkill();
                    temps.S_Id = Convert.ToInt32(s);
                    i.InternshipSkills.Add(temps);
                }
            }

            if (!string.IsNullOrWhiteSpace(Request.Form["perks"]))
            {
                foreach (string s in Request.Form["perks"].Split(','))
                {
                    InternshipPerk tempp = new InternshipPerk();
                    tempp.P_Id = Convert.ToInt32(s);
                    i.InternshipPerks.Add(tempp);
                }
            }

            if (!string.IsNullOrWhiteSpace(Request.Form["category"]))
            {
                i.InternshipIn = Convert.ToInt32(Request.Form["category"]);
            }
            else
            {
                flag         = true;
                err.Category = "You need to select A Category";
            }

            if (flag)
            {
                err.i = i;
                return(View(err));
            }

            try
            {
                string response = "";

                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(Baseurl);

                    client.DefaultRequestHeaders.Clear();

                    //Define request data format
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    //Sending request to find web api REST service resource GetAllEmployees using HttpClient

                    HttpResponseMessage Res = await client.PostAsJsonAsync("api/internshipsAPI/", i);

                    //Checking the response is successful or not which is sent using HttpClient
                    if (Res.IsSuccessStatusCode)
                    {
                        //Storing the response details recieved from web api
                        var StudentResponse = Res.Content.ReadAsStringAsync().Result;

                        //Deserializing the response recieved from web api and storing into the Employee list
                        response = JsonConvert.DeserializeObject <string>(StudentResponse);
                    }
                }

                if (response.Equals("exists"))
                {
                    err.Error = "Such an Internship already exists";
                    err.i     = i;
                    return(View(err));
                }
                else
                {
                    return(RedirectToAction("../Company/Internships"));
                }
            }
            catch
            {
                err.i = i;
                return(View(err));
            }
        }
Exemple #19
0
        public void Setup()
        {
            _context = ContextHelper.GetDatabaseContext();

            sut = new UserService(_context);

            userTeacher = new User
            {
                Id           = Guid.NewGuid(),
                City         = "City",
                Email        = "*****@*****.**",
                FirstName    = "John",
                HouseNumber  = 18,
                LastName     = "Doe",
                PasswordHash = Guid.NewGuid().ToString(),
                PhoneNumber  = "+3259874896",
                ZipCode      = 7890,
                UserName     = "******",
                StreetName   = "Easy Street",
                IsValidated  = false
            };

            company = new Company
            {
                CompanyTitle = "Test inc."
            };

            dtoTeacher = new UserReadDto
            {
                FirstName = userTeacher.FirstName,
                LastName  = userTeacher.LastName,
                Id        = userTeacher.Id
            };

            userCompany = new User
            {
                Id           = Guid.NewGuid(),
                City         = "City",
                Email        = "*****@*****.**",
                FirstName    = "Johnnie",
                HouseNumber  = 19,
                LastName     = "Doe",
                PasswordHash = Guid.NewGuid().ToString(),
                PhoneNumber  = "+3259874896",
                ZipCode      = 7890,
                UserName     = "******",
                StreetName   = "Easy Street",
                IsValidated  = false
            };

            dtoCompany = new UserReadDto
            {
                FirstName = userCompany.FirstName,
                LastName  = userCompany.LastName,
                Id        = userCompany.Id
            };

            userStudent = new User
            {
                Id           = Guid.NewGuid(),
                City         = "City",
                Email        = "*****@*****.**",
                FirstName    = "Henk",
                HouseNumber  = 17,
                LastName     = "Doe",
                PasswordHash = Guid.NewGuid().ToString(),
                PhoneNumber  = "+3259874896",
                ZipCode      = 7890,
                UserName     = "******",
                StreetName   = "Easy Street",
                IsValidated  = false
            };

            dtoStudent = new UserReadDto
            {
                FirstName = userStudent.FirstName,
                LastName  = userStudent.LastName,
                Id        = userStudent.Id
            };

            roleCompany = new Role
            {
                Id             = Guid.NewGuid(),
                Name           = "Company",
                NormalizedName = "COMPANY"
            };

            roleStudent = new Role
            {
                Id             = Guid.NewGuid(),
                Name           = "Student",
                NormalizedName = "STUDENT"
            };

            roleTeacher = new Role
            {
                Id             = Guid.NewGuid(),
                Name           = "Teacher",
                NormalizedName = "TEACHER"
            };

            internship = new Internship
            {
                RequiredFieldsOfStudy  = new List <string>(),
                AssignedStudents       = new List <string>(),
                Environment            = new List <string>(),
                TechnicalDescription   = "TechnicalDescription",
                ExtraRequirements      = "ExtraRequirements",
                ResearchTheme          = "ResearchTheme",
                Activities             = new List <string>(),
                RequiredStudentsAmount = 2,
                AdditionalRemarks      = "AdditionalRemarks",
                Periods         = new List <string>(),
                Description     = "Description",
                DateCreated     = DateTime.UtcNow,
                DateOfState     = DateTime.UtcNow,
                Id              = Guid.NewGuid(),
                InternshipState = 0,
                Reviewers       = new List <ReviewerInternships> {
                    new ReviewerInternships
                    {
                        ReviewedInternship = internship,
                        Reviewer           = userTeacher
                    }
                }
            };

            updateUser = new UserUpdate
            {
                FieldOfStudy = "UpdatedFOS"
            };

            userValidateDto = new UserValidateDto
            {
                Id        = userCompany.Id,
                Validated = true
            };

            pwDto = new ChangePasswordDto
            {
                OldPassword = userStudent.PasswordHash,
                NewPassword = "******"
            };

            companyUpdate = new CompanyUpdate
            {
                CompanyName = "Updated"
            };

            _context.Add(company);

            _context.Add(userCompany);
            _context.Roles.Add(roleCompany);
            _context.UserRoles.Add(new Microsoft.AspNetCore.Identity.IdentityUserRole <Guid>
            {
                RoleId = roleCompany.Id,
                UserId = userCompany.Id
            });
            _context.Add(userTeacher);
            _context.Roles.Add(roleTeacher);
            _context.UserRoles.Add(new Microsoft.AspNetCore.Identity.IdentityUserRole <Guid>
            {
                RoleId = roleTeacher.Id,
                UserId = userTeacher.Id
            });
            _context.Add(userStudent);
            _context.Roles.Add(roleStudent);
            _context.UserRoles.Add(new Microsoft.AspNetCore.Identity.IdentityUserRole <Guid>
            {
                RoleId = roleStudent.Id,
                UserId = userStudent.Id
            });
            _context.Add(internship);
            _context.SaveChanges();
        }
Exemple #20
0
 public async Task <Group> GetByInternshipAsync(Internship internship)
 {
     return(await UnitOfWork.Repository <Group>().Table.FirstOrDefaultAsync(g =>
                                                                            g.ClassId == internship.ClassId && g.Members.Select(s => s.Id).Contains(internship.StudentId)));
 }
Exemple #21
0
 public Group GetByInternship(Internship internship)
 {
     return(UnitOfWork.Repository <Group>().Table.FirstOrDefault(g =>
                                                                 g.ClassId == internship.ClassId && g.Members.Select(s => s.Id).Contains(internship.StudentId)));
 }
Exemple #22
0
        public IActionResult AddIntern(int id)
        {
            var model = new Internship();

            return(View(model));
        }
Exemple #23
0
        public void ReportServiceTest_CreateReport()
        {
            //Arrange

            List <Author> authors1 = new List <Author>();
            var           author1  = new Author
            {
                Name = "Bogdan",
                Id   = 1,
            };

            authors1.Add(author1);
            var dw = new DepartmentWork
            {
                Id       = 1,
                Authors  = authors1,
                Category = "Math",
                Content  = "Algebra",
                Intro    = "hello",
                Topic    = "Equations"
            };
            var testList = new List <DepartmentWork>()
            {
                dw
            };

            var dbSetMock1 = new Mock <DbSet <DepartmentWork> >();

            dbSetMock1.As <IQueryable <DepartmentWork> >().Setup(x => x.Provider).Returns(testList.AsQueryable().Provider);
            dbSetMock1.As <IQueryable <DepartmentWork> >().Setup(x => x.Expression).Returns(testList.AsQueryable().Expression);
            dbSetMock1.As <IQueryable <DepartmentWork> >().Setup(x => x.ElementType).Returns(testList.AsQueryable().ElementType);
            dbSetMock1.As <IQueryable <DepartmentWork> >().Setup(x => x.GetEnumerator()).Returns(testList.AsQueryable().GetEnumerator());

            var context1 = new Mock <DbContext>();

            context1.Setup(x => x.Set <DepartmentWork>()).Returns(dbSetMock1.Object);

            // Act
            var repository1 = new Repository <DepartmentWork, int>(context1.Object);
            var result1     = repository1.GetAll();

            List <Author> authors2 = new List <Author>();
            var           author2  = new Author
            {
                Name = "Bogdan",
                Id   = 1,
            };

            authors2.Add(author2);
            var gr = new Grant
            {
                Id           = 1,
                Participants = authors2,
                Name         = "Newton",
                Description  = "Algebra",
            };
            var testList2 = new List <Grant>()
            {
                gr
            };

            var dbSetMock2 = new Mock <DbSet <Author> >();

            dbSetMock2.As <IQueryable <Author> >().Setup(x => x.Provider).Returns(authors2.AsQueryable().Provider);
            dbSetMock2.As <IQueryable <Author> >().Setup(x => x.Expression).Returns(authors2.AsQueryable().Expression);
            dbSetMock2.As <IQueryable <Author> >().Setup(x => x.ElementType).Returns(authors2.AsQueryable().ElementType);
            dbSetMock2.As <IQueryable <Author> >().Setup(x => x.GetEnumerator()).Returns(authors2.AsQueryable().GetEnumerator());

            var context2 = new Mock <DbContext>();

            context2.Setup(x => x.Set <Author>()).Returns(dbSetMock2.Object);

            // Act
            var repository2 = new Repository <Author, int>(context2.Object);
            var result2     = repository2.GetAll();

            var repo = new ScientificReportData.Models.Report
            {
                Id             = 1,
                Date           = new DateTime(1999, 12, 1),
                DepartmentWork = "AMI",
                Conferences    = "none",
                Contetnt       = "smth",
                Intro          = "Begin"
            };
            List <Report> reports = new List <Report>();

            reports.Add(repo);

            List <Author> authors = new List <Author>();
            var           author  = new Author
            {
                Name = "Bogdan",
                Id   = 1,
            };

            authors.Add(author);

            var publication = new Publication
            {
                Status  = "prove",
                Authors = authors,
                Id      = 1,
                Date    = new DateTime(2009, 12, 1),
                Topic   = "sfs",
                Type    = "math"
            };
            List <Publication> publications = new List <Publication>();

            publications.Add(publication);

            var internship = new Internship
            {
                Name = "mine",
                Id   = 1
            };

            List <Internship> internships = new List <Internship>();

            internships.Add(internship);

            var user = new ScientificReportData.Models.User
            {
                Name           = "ME",
                Birthdate      = new DateTime(1992, 1, 12),
                DegreeLevel    = "BACHELOR",
                DegreeDate     = new DateTime(2010, 1, 12),
                GraduationDate = new DateTime(2011, 1, 12),
                Title          = "124rs",
                TitleDate      = new DateTime(2016, 1, 12),
                Faculty        = "AMI",
                Department     = "AM",
                IsAdmin        = false,
                IsApproved     = true,
                Reports        = reports,
                Publications   = publications,
                Internships    = internships,
            };

            var testarray = new List <User>()
            {
                user
            };

            //var testarray = new List<Publication>() { pb };

            var intro = new StringBuilder();

            intro.Append(
                $"Рік народження: {user.Birthdate.Year}")
            .Append(Environment.NewLine)
            .Append($"Рік закінчення ВНЗ {user.GraduationDate}").Append(Environment.NewLine)
            .Append($"Науковий ступінь: {user.DegreeLevel} рік захисту {user.DegreeDate.Year}")
            .Append(Environment.NewLine)
            .Append($"Вчене звання: {user.Title} рік присвоєння {user.TitleDate.Year}"
                    );

            var userAsAuthor = repository2.GetAll().FirstOrDefault(a => a.Name == user.Name);
            var works        = repository1.GetAll().Where(w => w.Authors.Contains(userAsAuthor));
            var section      = new StringBuilder();

            foreach (var work in works)
            {
                section.Append($"Teмa: {work.Topic}, {work.Category}, {work.Intro}")
                .Append(Environment.NewLine)
                .Append(Environment.NewLine)
                .Append(work.Content)
                .Append(Environment.NewLine)
                .Append(Environment.NewLine);
            }

            var report = new Report
            {
                Date           = DateTime.Today.Date,
                Intro          = intro.ToString(),
                DepartmentWork = section.ToString(),
            };
            var testarray1 = new List <Report>()
            {
                report
            };

            var dbSetMock = new Mock <DbSet <Report> >();

            dbSetMock.As <IQueryable <Report> >().Setup(x => x.Provider).Returns(testarray1.AsQueryable().Provider);
            dbSetMock.As <IQueryable <Report> >().Setup(x => x.Expression).Returns(testarray1.AsQueryable().Expression);
            dbSetMock.As <IQueryable <Report> >().Setup(x => x.ElementType).Returns(testarray1.AsQueryable().ElementType);
            dbSetMock.As <IQueryable <Report> >().Setup(x => x.GetEnumerator()).Returns(testarray1.AsQueryable().GetEnumerator());

            var context = new Mock <DbContext>();

            context.Setup(x => x.Set <Report>()).Returns(dbSetMock.Object);

            // Act
            var repository = new Repository <Report, int>(context.Object);
            var result     = repository.GetAll();

            // Assert
            Assert.AreEqual(report, result.ToList()[0]);
        }
Exemple #24
0
 public async Task DeleteInternship(Internship internship)
 {
     _context.Internships.Remove(internship);
     await _context.SaveChangesAsync();
 }
Exemple #25
0
        public void ReportServiceTest_CreateViewModel()
        {
            List <Author> authors = new List <Author>();
            var           author  = new Author
            {
                Name = "Began",
                Id   = 1,
            };

            authors.Add(author);
            var pb = new Publication()
            {
                Id      = 1,
                Authors = authors,
                Topic   = "Newton",
                Status  = "closed",
                Type    = "math",
                Date    = new DateTime(2019, 8, 1),
            };
            var testarray = new List <Publication>()
            {
                pb
            };


            var dbSetMock = new Mock <DbSet <Publication> >();

            dbSetMock.As <IQueryable <Publication> >().Setup(x => x.Provider).Returns(testarray.AsQueryable().Provider);
            dbSetMock.As <IQueryable <Publication> >().Setup(x => x.Expression).Returns(testarray.AsQueryable().Expression);
            dbSetMock.As <IQueryable <Publication> >().Setup(x => x.ElementType).Returns(testarray.AsQueryable().ElementType);
            dbSetMock.As <IQueryable <Publication> >().Setup(x => x.GetEnumerator()).Returns(testarray.AsQueryable().GetEnumerator());

            var context = new Mock <DbContext>();

            context.Setup(x => x.Set <Publication>()).Returns(dbSetMock.Object);

            // Act
            var repository = new Repository <Publication, int>(context.Object);
            var result     = repository.GetAll();

            //Arrange

            var gr = new Grant
            {
                Id           = 1,
                Participants = authors,
                Name         = "Newton",
                Description  = "Algebra",
            };
            var testList = new List <Grant>()
            {
                gr
            };

            var dbSetMock1 = new Mock <DbSet <Grant> >();

            dbSetMock1.As <IQueryable <Grant> >().Setup(x => x.Provider).Returns(testList.AsQueryable().Provider);
            dbSetMock1.As <IQueryable <Grant> >().Setup(x => x.Expression).Returns(testList.AsQueryable().Expression);
            dbSetMock1.As <IQueryable <Grant> >().Setup(x => x.ElementType).Returns(testList.AsQueryable().ElementType);
            dbSetMock1.As <IQueryable <Grant> >().Setup(x => x.GetEnumerator()).Returns(testList.AsQueryable().GetEnumerator());

            var context1 = new Mock <DbContext>();

            context1.Setup(x => x.Set <Grant>()).Returns(dbSetMock1.Object);

            // Act
            var repository1 = new Repository <Grant, int>(context1.Object);
            var result1     = repository1.GetAll();

            var dw = new DepartmentWork
            {
                Id       = 1,
                Authors  = authors,
                Category = "Math",
                Content  = "Algebra",
                Intro    = "hello",
                Topic    = "Equations"
            };
            var testList1 = new List <DepartmentWork>()
            {
                dw
            };

            var dbSetMock2 = new Mock <DbSet <DepartmentWork> >();

            dbSetMock2.As <IQueryable <DepartmentWork> >().Setup(x => x.Provider).Returns(testList1.AsQueryable().Provider);
            dbSetMock2.As <IQueryable <DepartmentWork> >().Setup(x => x.Expression).Returns(testList1.AsQueryable().Expression);
            dbSetMock2.As <IQueryable <DepartmentWork> >().Setup(x => x.ElementType).Returns(testList1.AsQueryable().ElementType);
            dbSetMock2.As <IQueryable <DepartmentWork> >().Setup(x => x.GetEnumerator()).Returns(testList1.AsQueryable().GetEnumerator());

            var context2 = new Mock <DbContext>();

            context2.Setup(x => x.Set <DepartmentWork>()).Returns(dbSetMock2.Object);

            // Act
            var repository2 = new Repository <DepartmentWork, int>(context2.Object);
            var result2     = repository2.GetAll();

            var Conf = new Conference
            {
                Date         = new DateTime(2008, 3, 1, 7, 0, 0),
                Id           = 1,
                Description  = "sad",
                ImgPath      = "sss",
                Likes        = 145,
                Title        = "Math",
                Watches      = 300,
                Participants = authors,
            };

            var testList2 = new List <Conference>()
            {
                Conf
            };

            var dbSetMock3 = new Mock <DbSet <Conference> >();

            dbSetMock3.As <IQueryable <Conference> >().Setup(x => x.Provider).Returns(testList2.AsQueryable().Provider);
            dbSetMock3.As <IQueryable <Conference> >().Setup(x => x.Expression).Returns(testList2.AsQueryable().Expression);
            dbSetMock3.As <IQueryable <Conference> >().Setup(x => x.ElementType).Returns(testList2.AsQueryable().ElementType);
            dbSetMock3.As <IQueryable <Conference> >().Setup(x => x.GetEnumerator()).Returns(testList2.AsQueryable().GetEnumerator());

            var context3 = new Mock <DbContext>();

            context3.Setup(x => x.Set <Conference>()).Returns(dbSetMock3.Object);

            // Act
            var repository3 = new Repository <Conference, int>(context3.Object);
            var result3     = repository3.GetAll();

            var repo = new ScientificReportData.Models.Report
            {
                Id             = 1,
                Date           = new DateTime(1999, 12, 1),
                DepartmentWork = "AMI",
                Conferences    = "none",
                Contetnt       = "smth",
                Intro          = "Begin"
            };
            List <Report> reports = new List <Report>();

            reports.Add(repo);

            authors.Add(author);

            var publication = new Publication
            {
                Status  = "prove",
                Authors = authors,
                Id      = 1,
                Date    = new DateTime(2009, 12, 1),
                Topic   = "sfs",
                Type    = "math"
            };
            List <Publication> publications = new List <Publication>();

            publications.Add(publication);

            var internship = new Internship
            {
                Name = "mine",
                Id   = 1
            };

            List <Internship> internships = new List <Internship>();

            internships.Add(internship);

            var user = new ScientificReportData.Models.User
            {
                Name           = "ME",
                Birthdate      = new DateTime(1992, 1, 12),
                DegreeLevel    = "BACHELOR",
                DegreeDate     = new DateTime(2010, 1, 12),
                GraduationDate = new DateTime(2011, 1, 12),
                Title          = "124rs",
                TitleDate      = new DateTime(2016, 1, 12),
                Faculty        = "AMI",
                Department     = "AM",
                IsAdmin        = false,
                IsApproved     = true,
                Reports        = reports,
                Publications   = publications,
                Internships    = internships,
            };

            var Curuser = new ScientificReportData.Models.User
            {
                Name           = "NOTME",
                Birthdate      = new DateTime(1992, 1, 12),
                DegreeLevel    = "BACHELOR",
                DegreeDate     = new DateTime(2010, 1, 12),
                GraduationDate = new DateTime(2011, 1, 12),
                Title          = "124rs",
                TitleDate      = new DateTime(2016, 1, 12),
                Faculty        = "AMI",
                Department     = "AM",
                IsAdmin        = false,
                IsApproved     = true,
                Reports        = reports,
                Publications   = publications,
                Internships    = internships,
            };

            var publicationres = result.Where(p => p.Authors.Any(a => a.Name == user.Name))?.ToList();
            var grantsres      = result1.Where(p => p.Participants.Any(a => a.Name == user.Name))?.ToList();
            var depWorksres    = result2.Where(p => p.Authors.Any(a => a.Name == user.Name))?.ToList();
            var conferencesres = result3.Where(p => p.Participants.Any(a => a.Name == user.Name))?.ToList();

            var resulting = new ReportViewModel
            {
                User            = user,
                Publications    = publicationres ?? new List <Publication>(),
                DepartmentWorks = depWorksres ?? new List <DepartmentWork>(),
                Conferences     = conferencesres ?? new List <Conference>(),
                Grants          = grantsres ?? new List <Grant>()
            };

            using (var mack = AutoMock.GetLoose())
            {
                //Arrange
                mack.Mock <IReportService>()
                .Setup(x => x.CreateViewModel(user, DateTime.MinValue, DateTime.MaxValue))
                .Returns(GetSampleViewModel(resulting));
                //Act
                var cls = mack.Create <IReportService>();

                var expected = GetSampleViewModel(resulting);

                var actual = cls.CreateViewModel(user, DateTime.MinValue, DateTime.MaxValue);
                //Assert
                Assert.AreEqual(actual, expected);
            };
        }
Exemple #26
0
        public async Task <Internship> Put(int id, [FromBody] Internship value)
        {
            await _internshipManager.Update(id, value);

            return(await _internshipManager.Read(id));
        }
        public static async Task Seed(ApplicationDbContext context, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager)
        {
            await userManager.CreateAsync(new ApplicationUser { Email = "*****@*****.**", UserName = "******" }, "Password123.");

            await userManager.CreateAsync(new ApplicationUser { Email = "*****@*****.**", UserName = "******" }, "Password123.");

            await userManager.CreateAsync(new ApplicationUser { Email = "*****@*****.**", UserName = "******" }, "Password123.");

            await userManager.CreateAsync(new ApplicationUser { Email = "*****@*****.**", UserName = "******" }, "Password123.");

            await userManager.CreateAsync(new ApplicationUser { Email = "*****@*****.**", UserName = "******" }, "Password123.");

            await roleManager.CreateAsync(new IdentityRole { Name = "Student" });

            await roleManager.CreateAsync(new IdentityRole { Name = "Company" });

            var student1 = await userManager.FindByEmailAsync("*****@*****.**");

            var student2 = await userManager.FindByEmailAsync("*****@*****.**");

            var student3 = await userManager.FindByEmailAsync("*****@*****.**");

            var company1 = await userManager.FindByEmailAsync("*****@*****.**");

            var company2 = await userManager.FindByEmailAsync("*****@*****.**");

            var roleStudent = await roleManager.FindByNameAsync("Student");

            var roleCompany = await roleManager.FindByNameAsync("Company");

            #region Set Roles
            await userManager.AddToRoleAsync(student1, roleStudent.Name);

            await userManager.AddToRoleAsync(student2, roleStudent.Name);

            await userManager.AddToRoleAsync(student3, roleStudent.Name);

            await userManager.AddToRoleAsync(company1, roleCompany.Name);

            await userManager.AddToRoleAsync(company2, roleCompany.Name);

            #endregion

            #region Students
            string cvFilePath1 = "/DatabaseAccess/Resources/CVs/cv.pdf";

            byte[] contents = File.ReadAllBytes(parentDirectory + cvFilePath1);

            List <Student> students = new List <Student> {
                new Student()
                {
                    Firstname      = "Simona",
                    Lastname       = "Burlacu",
                    University     = "UBB",
                    College        = "Facultatea de Matematica-Informatica",
                    Specialization = "Informatica-Romana",
                    Cv             = contents,
                    Year           = 3,
                    IdUser         = student1.Id
                },
                new Student()
                {
                    Firstname      = "Alex",
                    Lastname       = "Cornea",
                    University     = "UBB",
                    College        = "Facultatea de Matematica-Informatica",
                    Specialization = "Informatica-Romana",
                    Year           = 3,
                    Cv             = contents,
                    IdUser         = student2.Id
                },
                new Student()
                {
                    Firstname      = "Bogdan",
                    Lastname       = "Gheorghe",
                    University     = "UBB",
                    College        = "Facultatea de Matematica-Informatica",
                    Specialization = "Informatica-Romana",
                    Year           = 3,
                    Cv             = contents,
                    IdUser         = student3.Id
                }
            };
            #endregion

            #region Companies
            List <Company> companies = new List <Company> {
                new Company
                {
                    Name        = "Accesa",
                    Description = "O companie ca oricare alta",
                    Url         = "www.google.com",
                    IdUser      = company1.Id
                },
                new Company()
                {
                    Name        = "Yardi",
                    Description = "O companie",
                    Url         = "www.yahoo.com",
                    IdUser      = company2.Id
                }
            };
            #endregion

            foreach (var stud in students)
            {
                context.Students.Add(stud);
            }
            context.SaveChanges();

            foreach (var comp in companies)
            {
                context.Companies.Add(comp);
            }
            context.SaveChanges();

            #region Internships
            var        accesa            = context.Companies.Where(c => c.Name == "Accesa").FirstOrDefault();
            Internship internshipAccesa1 = new Internship()
            {
                Description = "Internship React",
                Places      = 8,
                Topics      = "React, JavaScript",
                Start       = new DateTime(2018, 3, 3),
                End         = new DateTime(2018, 5, 3),
                Name        = "Best Internship EU",
                Weeks       = 2,
                CompanyId   = accesa.Id
            };

            Internship internshipAccesa2 = new Internship()
            {
                Description = "Internship Azure",
                Places      = 8,
                Topics      = "Azure functions, Serverless",
                Start       = new DateTime(2017, 10, 3),
                End         = new DateTime(2017, 11, 3),
                Name        = "Internship Cloud",
                Weeks       = 2,
                CompanyId   = accesa.Id
            };

            Internship internshipAccesa3 = new Internship()
            {
                Description = "Internship Mobile",
                Places      = 8,
                Topics      = "React Native, Android",
                Start       = new DateTime(2019, 1, 1),
                End         = new DateTime(2019, 5, 1),
                Name        = "Internship Aplicatii Mobile",
                Weeks       = 16,
                CompanyId   = accesa.Id
            };

            Internship internshipAccesa4 = new Internship()
            {
                Description = "Internship Machine Learning",
                Places      = 8,
                Topics      = "AI, ML, Deep Learning",
                Start       = new DateTime(2019, 1, 1),
                End         = new DateTime(2019, 3, 1),
                Name        = "Internship Inteligenta Artificiala",
                Weeks       = 8,
                CompanyId   = accesa.Id
            };

            context.Internships.Add(internshipAccesa1);
            context.Internships.Add(internshipAccesa2);
            context.Internships.Add(internshipAccesa3);
            context.Internships.Add(internshipAccesa4);
            context.SaveChanges();

            accesa.Internships.Add(internshipAccesa1);
            accesa.Internships.Add(internshipAccesa2);
            accesa.Internships.Add(internshipAccesa3);
            accesa.Internships.Add(internshipAccesa4);
            context.SaveChanges();
            #endregion

            var simona = context.Students.Where(s => s.Firstname == "Simona").FirstOrDefault();
            var alex   = context.Students.Where(s => s.Firstname == "Alex").FirstOrDefault();
            var bogdan = context.Students.Where(s => s.Firstname == "Bogdan").FirstOrDefault();

            #region Applications
            var application1 = new Application()
            {
                InternshipId = internshipAccesa1.Id,
                StudentId    = alex.Id,
                Status       = Enums.ApplicationStatus.APLICAT
            };
            context.Applications.Add(application1);
            context.SaveChanges();

            var application2 = new Application()
            {
                InternshipId = internshipAccesa2.Id,
                StudentId    = alex.Id,
                Status       = Enums.ApplicationStatus.CONTACTAT
            };
            context.Applications.Add(application2);
            context.SaveChanges();

            var application3 = new Application()
            {
                InternshipId = internshipAccesa1.Id,
                StudentId    = simona.Id,
                Status       = Enums.ApplicationStatus.ADMIS
            };
            context.Applications.Add(application3);
            context.SaveChanges();

            var application4 = new Application()
            {
                InternshipId = internshipAccesa1.Id,
                StudentId    = bogdan.Id,
                Status       = Enums.ApplicationStatus.APROBAT
            };
            context.Applications.Add(application4);
            context.SaveChanges();

            var application5 = new Application()
            {
                InternshipId = internshipAccesa3.Id,
                StudentId    = alex.Id,
                Status       = Enums.ApplicationStatus.APROBAT
            };
            context.Applications.Add(application5);
            context.SaveChanges();

            var application6 = new Application()
            {
                InternshipId = internshipAccesa4.Id,
                StudentId    = alex.Id,
                Status       = Enums.ApplicationStatus.RESPINS
            };
            context.Applications.Add(application6);
            context.SaveChanges();

            string imageFilePath1 = "/DatabaseAccess/Resources/internship2.jpg";
            Post   post1          = new Post()
            {
                Title        = "Un nou internship",
                Date         = new DateTime(2019, 1, 30),
                InternshipId = 1,
                Last         = false,
                Text         = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
                Image        = File.ReadAllBytes(parentDirectory + imageFilePath1)
            };

            context.Posts.Add(post1);
            context.SaveChanges();


            string imageFilePath2 = "/DatabaseAccess/Resources/internship1.png";
            Post   post2          = new Post()
            {
                Title        = "Detalii despre selectie",
                Date         = new DateTime(2019, 2, 10),
                InternshipId = 1,
                Last         = false,
                Text         = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
                Image        = File.ReadAllBytes(parentDirectory + imageFilePath2)
            };

            context.Posts.Add(post2);
            context.SaveChanges();
            #endregion

            #region Ratings

            List <Rating> ratings = new List <Rating>
            {
                new Rating
                {
                    InternshipId     = 1,
                    StudentId        = 1,
                    RatingCompany    = 4,
                    RatingInternship = 5,
                    RatingMentors    = 5,
                    Date             = new DateTime(2018, 05, 10),
                    Testimonial      = "Cel mai fain internship din toate (1) pe care le-am avut!"
                },
                new Rating
                {
                    InternshipId     = 1,
                    StudentId        = 2,
                    RatingCompany    = 3,
                    RatingInternship = 3,
                    RatingMentors    = 3,
                    Date             = new DateTime(2018, 07, 23),
                    Testimonial      = "Am invatat foarte multe in cadrul acestui internship.Recomand!"
                },
            };

            foreach (var rating in ratings)
            {
                context.Ratings.Add(rating);
            }
            context.SaveChanges();

            #endregion
        }
Exemple #28
0
        public static void Initialize(StageCheckContext context)
        {
            context.Database.EnsureCreated();

            if (context.Internships.Any())
            {
                return;
            }

            var internships = new Internship[]
            {
                new Internship {
                    Title       = "Mechatronica hbo stage 2e jaars",
                    Description = "Uitdagende stageopdracht beschikbaar, indien interesse neem contact op",
                    StudyId     = 1,
                    CompanyId   = 2,
                },

                new Internship {
                    Title       = "ICT hbo afstudeerstage",
                    Description = "Hele leuke en uitdagende afstudeeropdracht, reageer snel want we hebben maar plaats voor een student",
                    StudyId     = 2,
                    CompanyId   = 1,
                },

                new Internship {
                    Title       = "Bedrijfskunde hbo 2e jaars stage",
                    Description = "2 stageplekken vrij, wij zoeken een enthousiaste student die veel wil leren. Neem contact op voor meer informatie",
                    StudyId     = 3,
                    CompanyId   = 3,
                },

                new Internship {
                    Title       = "Applied Science hbo afstudeerstage",
                    Description = "3 Uitdagende stageplek beschikbaar, voor meer informatie neem contact met ons op",
                    StudyId     = 4,
                    CompanyId   = 4,
                },

                new Internship {
                    Title       = "hbo software stage",
                    Description = "Leerzame stageplek beschikbaar, neem snel contact op voor meer informatie als je geïnteresseerd bent",
                    StudyId     = 2,
                    CompanyId   = 5,
                },
            };

            foreach (Internship i in internships)
            {
                context.Internships.Add(i);
            }

            context.SaveChanges();

            if (context.Studies.Any())
            {
                return;
            }

            var studies = new Study[]
            {
                new Study {
                    Name = "Mechatronica"
                },

                new Study {
                    Name = "ICT"
                },

                new Study {
                    Name = "Bedrijfskunde"
                },

                new Study {
                    Name = "Applied Science"
                },
            };

            foreach (Study s in studies)
            {
                context.Studies.Add(s);
            }

            context.SaveChanges();

            if (context.Companies.Any())
            {
                return;
            }

            var companies = new Company[]
            {
                new Company {
                    Name                = "Rockstars IT",
                    StreetName          = "Lekkerbeetjesstraat",
                    HouseNumber         = 8,
                    HouseNumberAddition = null,
                    ZipCode             = "5211 AL",
                    City                = "'s-Hertogenbosch",
                    WebSite             = "www.teamrockstars.nl",
                    PhoneNumber         = "+31736157777"
                },

                new Company {
                    Name                = "Etemf B.V.",
                    StreetName          = "Simon De Cockstraat",
                    HouseNumber         = 4,
                    HouseNumberAddition = null,
                    ZipCode             = "5048 AW",
                    City                = "Tilburg",
                    WebSite             = "www.etemf.nl",
                    PhoneNumber         = "+31135424372"
                },

                new Company {
                    Name                = "RUG Fac. Econ.& Bedrijfskunde vakgroep IM&S",
                    StreetName          = "Nettelbosje",
                    HouseNumber         = 2,
                    HouseNumberAddition = null,
                    ZipCode             = "9747 AE",
                    City                = "Groningen",
                    WebSite             = "www.rug.nl/feb/",
                    PhoneNumber         = "+31503633453"
                },

                new Company {
                    Name                = "HZ University of Applied Sciences",
                    StreetName          = "Het Groene Woud",
                    HouseNumber         = 1,
                    HouseNumberAddition = null,
                    ZipCode             = "4331 NB",
                    City                = "Middelburg",
                    WebSite             = "www.hz.nl",
                    PhoneNumber         = "+31118489000"
                },

                new Company {
                    Name                = "Philips Software Concepts",
                    StreetName          = "High Tech Campus",
                    HouseNumber         = 34,
                    HouseNumberAddition = null,
                    ZipCode             = "5656 AE",
                    City                = "Eindhoven",
                    WebSite             = "www.hrn.philips.com/cv",
                    PhoneNumber         = "+31611520501"
                },
            };

            foreach (Company c in companies)
            {
                context.Companies.Add(c);
            }

            context.SaveChanges();
        }
Exemple #29
0
 public AppliedInternship(User user, Internship intern)
 {
     User       = user;
     Internship = intern;
 }
Exemple #30
0
 public IActionResult InternshipApply(int?id, ApplyInternship fromData)
 {
     // the User is student
     // Make changes to AppliedInternship table.
     //  make nortfication.
     using (GlobalDBContext _context = new GlobalDBContext())
     {
         string FinalCVPath;
         string FinalCLPath;
         string FinalCLString = null;
         // CV
         if (fromData.TemporaryCV != null && fromData.TemporaryCV.Length > 0)
         {
             string UserCVFolder = _env.WebRootPath + @"\uploads\UserCV\";
             // File of code need to be Tested
             FinalCVPath = HelpersFunctions.StoreFile(UserCVFolder, fromData.TemporaryCV);
         }
         else
         {
             if (fromData.isCVExisting)
             {
                 UserDocument Doc = _context.UserDocuments.Include(u => u.User).FirstOrDefault(p =>
                                                                                               p.User.UserId == _user.UserId && p.DocumentType == "CV");
                 FinalCVPath = Doc.DocumentPath;
             }
             else
             {
                 FinalCVPath = null;
             }
         }
         // COVER Letter
         if (fromData.TemporaryCL != null && fromData.TemporaryCL.Length > 0)
         {
             string UserCLFolder = _env.WebRootPath + @"\uploads\UserCL\";
             // File of code need to be Tested
             FinalCLPath = HelpersFunctions.StoreFile(UserCLFolder, fromData.TemporaryCL);
         }
         else
         {
             if (fromData.isCLExisting)
             {
                 UserDocument Doc = _context.UserDocuments.Include(u => u.User).FirstOrDefault(p =>
                                                                                               p.User.UserId == _user.UserId && p.DocumentType == "CL");
                 FinalCLPath = Doc.DocumentPath;
             }
             else
             {
                 FinalCLPath = null;
                 if (fromData.isCLTextArea)
                 {
                     FinalCLString = fromData.WrittenCL;
                 }
                 else
                 {
                     FinalCLString = null;
                 }
             }
         }
         Internship intern = _context.Internships.Find(id);
         // AppliedInternship constructor takes User and Internship object to create AppliedInternship object
         AppliedInternship APP_Intern = new AppliedInternship(_user, intern)
         {
             TempCVPath      = FinalCVPath,
             TempCLPath      = FinalCLPath,
             CoverLetterText = FinalCLString,
             EmployerStatus  = "Pending"
         };
         // Adding who applied the intership
         _context.AppliedInternships.Add(APP_Intern);
         _context.SaveChanges();
         return(View());
     }
 }