Пример #1
0
        public ActionResult FreelancerProfile(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Person p = db.People.FirstOrDefault(x => x.PersonId == id);

            if (p == null)
            {
                return(HttpNotFound());
            }
            AspNetUser aspNetUser = db.AspNetUsers.FirstOrDefault(x => x.Id == p.User_AccountID);
            Freelancer freelancer = db.Freelancers.FirstOrDefault(f => f.FreelancerId == p.PersonId);
            var        Fskills    = db.FreelancerSkills.Where(s => s.FreelancerId == freelancer.FreelancerId);

            FreelancerViewModel freelancerViewModel = new FreelancerViewModel();

            freelancerViewModel.Person          = p;
            freelancerViewModel.AspNetUser      = aspNetUser;
            freelancerViewModel.Freelancer      = freelancer;
            freelancerViewModel.FreelancerSkill = Fskills;

            return(View(freelancerViewModel));
        }
Пример #2
0
        private void StartSubMenuSelectEmployeeOper(AddOperation addOperation)
        {
            var workData = GetWorkData(addOperation);

            switch (addOperation)
            {
            case AddOperation.AddDirector:
                Director addDirector = new Director(workData.name, workData.monthSalary, workData.bonus, workData.position);
                directorRepository.AddEmployee <Director>(addDirector, Settings.directorsFile);
                ShowDirectorMenu();
                break;

            case AddOperation.AddProger:
                Proger addProger = new Proger(workData.name, workData.monthSalary, workData.position);
                directorRepository.AddEmployee <Proger>(addProger, Settings.progersFile);
                ShowDirectorMenu();
                break;

            case AddOperation.AddFreelancer:
                Freelancer addFreelancer = new Freelancer(workData.name, workData.monthSalary, workData.position);
                directorRepository.AddEmployee <Freelancer>(addFreelancer, Settings.freelancerFile);
                ShowDirectorMenu();
                break;

            default:
                ShowDirectorMenu();
                break;
            }
        }
Пример #3
0
        public bool updateFreelancer(Freelancer freelancer)
        {
            bool success = false;

            query = @"UPDATE  freelancer Set Description = @Description, Price = @Price, Work = @Work WHERE  StudentId = @StudentId";

            using (MySqlCommand command = new MySqlCommand(query, new MySqlConnection(getConnectionString())))
            {
                //General
                command.Parameters.AddWithValue("@StudentId", freelancer.StudentId);
                command.Parameters.AddWithValue("@Description", freelancer.Description);
                command.Parameters.AddWithValue("@Price", freelancer.Price);
                command.Parameters.AddWithValue("@Work", freelancer.Work);

                command.Connection.Open();
                command.CommandType = System.Data.CommandType.Text;
                command.ExecuteNonQuery();

                command.Connection.Close();

                success = true;
            }

            return(success);
        }
Пример #4
0
        internal static int Main()
        {
            // Using an interface makes the code more flexible
            // but ensures at the same time that the commitments
            // of an Employee are fulfilled.
            IEmployable Max = new FullTimeEmployee()
            {
                FirstName    = "Max",
                LastName     = "Mustermann",
                AnnualSalary = 60000
            };

            Console.WriteLine($"{Max.GetFullName()} earns {Max.GetMonthlySalary()} per month.");
            Max.WorkOn();

            Console.WriteLine();

            IEmployable Moritz = new Freelancer()
            {
                FirstName   = "Moritz",
                LastName    = "Mustermann",
                HourlyWage  = 200,
                HoursWorked = 20
            };

            Console.WriteLine($"{Moritz.GetFullName()} worked {((Freelancer)Moritz).HoursWorked} hours and earned {Moritz.GetMonthlySalary()} last month.");
            Moritz.WorkOn();

            Console.WriteLine("\nProgram end reached. Press the any-key to exit.");
            Console.ReadKey();
            return(0);
        }
Пример #5
0
        public Freelancer Read(string login)
        {
            Freelancer freelancer = null;

            SqlCommand cmd = new SqlCommand();

            cmd.Connection = connectionDB;

            cmd.CommandText = @"SELECT * FROM  Pessoa, Freelancer WHERE Login = @login AND pessoa.id = Freelancer.freelancer_id";

            cmd.Parameters.AddWithValue("@login", login);

            SqlDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                freelancer = new Freelancer
                {
                    // Criando objeto pessoa que existe no banco
                    Id          = (int)reader["Id"],
                    Nome        = (string)reader["Nome"],
                    Cpf         = (string)reader["Cpf"],
                    Login       = (string)reader["Login"],
                    Senha       = (string)reader["Senha"],
                    Status      = (int)reader["Status"],
                    Telefone    = (string)reader["Telefone"],
                    QtdProjetos = (int)reader["QtdProjetos"],
                    MediaNota   = (decimal)reader["MediaNota"],
                    Email       = (string)reader["Email"],
                    Ra          = (string)reader["Ra"],
                    Experiencia = (string)reader["Experiencia"]
                };
            }
            return(freelancer);
        }
Пример #6
0
        public IHttpActionResult GetRegisteredEventsForFreelancerS()
        {
            Freelancer freelancer = db.Freelancers.Find(User.Identity.GetUserId());

            if (freelancer == null)
            {
                return(NotFound());
            }

            var freelancerRegisteredEvents = new
            {
                freelancerId        = freelancer.Id,
                freelancerFirstName = freelancer.FirstName,
                freelancerLastName  = freelancer.LastName,
                RegEvents           = freelancer.RegEvents.Select(thisEvent =>
                                                                  new
                {
                    thisEvent.EventId,
                    thisEvent.EventName,
                    //thisEvent.StartDate,
                    //thisEvent.EndDate,
                    StartDate = thisEvent.StartDate.ToLocalTime().ToString("MM/dd/yyyy @ h:mm tt"),
                    EndDate   = thisEvent.EndDate.ToLocalTime().ToString("MM/dd/yyyy @ h:mm tt"),
                    thisEvent.Description
                })
            };

            return(Ok(freelancerRegisteredEvents));
            //return Ok(freelancer);
        }
Пример #7
0
        public void Create(Freelancer freelancer)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection = connectionDB;

            // Comando que sera escrito no banco de dados
            cmd.CommandText = @"exec AddFreela @nome, @login, @senha, @email, @telefone, @qtdProjetos,
                                               @mediaNota, @status, @cpf, @ra, @experiencia";

            cmd.Parameters.AddWithValue("@nome", freelancer.Nome);
            cmd.Parameters.AddWithValue("@login", freelancer.Login);
            cmd.Parameters.AddWithValue("@senha", freelancer.Senha);
            cmd.Parameters.AddWithValue("@status", freelancer.Status);
            cmd.Parameters.AddWithValue("@telefone", freelancer.Telefone);
            cmd.Parameters.AddWithValue("@qtdprojetos", freelancer.QtdProjetos);
            cmd.Parameters.AddWithValue("@medianota", freelancer.MediaNota);
            cmd.Parameters.AddWithValue("@email", freelancer.Email);

            // Colocando os dados recebidos pelo objeto cliente na string sql
            cmd.Parameters.AddWithValue("@cpf", freelancer.Cpf);
            cmd.Parameters.AddWithValue("@ra", freelancer.Ra);
            cmd.Parameters.AddWithValue("@experiencia", freelancer.Experiencia);

            // Execução da string qld no banco
            cmd.ExecuteNonQuery();
        }
Пример #8
0
        public async Task <object> Register([FromBody] RegisterDto model)
        {
            if (ModelState.IsValid)
            {
                var user = new IdentityUser
                {
                    UserName = model.Email,//model.GetUserName(),
                    Email    = model.Email
                };

                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await _signInManager.SignInAsync(user, false);

                    var freelancer = new Freelancer
                    {
                        Id        = new Guid(user.Id),
                        FirstName = model.FirstName,
                        LastName  = model.LastName
                    };
                    _WorkRepository.AddFreelancer(freelancer);
                    _WorkRepository.Save();
                    return(await GenerateJwtToken(model.Email, user));
                }

                return(result.Errors);
            }
            return(BadRequest("Invalid registration..!\n" +
                              "Please fill out and resend registration model variables\n" +
                              "FirstName': 'Name', 'LastName': 'Name', 'Email': 'email', 'Password': '******'"));
        }
Пример #9
0
        public IHttpActionResult PostFreelancer(Freelancer freelancer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Users.Add(freelancer);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (FreelancerExists(freelancer.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = freelancer.Id }, freelancer));
        }
Пример #10
0
 public bool Equals(Freelancer another)
 {
     return(Name.Equals(another.Name) &&
            MonyPerHour.Equals(another.MonyPerHour) &&
            Experience.Equals(another.Experience) &&
            Gender.Equals(another.Gender));
 }
Пример #11
0
        // TODO: Возможность группе возможных будущих сотруднику подать свое "резюме", после чего передать управлению TL, который отберёт сотрудников в свою команду
        static void Main(string[] args)
        {
            TeamLead tl = new TeamLead(20, "Jame", "Felrt");

            tl.ReadAsyncMeetingReview();

            IWorker eml_a  = new Employer(23, "Alex", "Arak");
            IWorker frl_r  = new Freelancer(24, "Rob", "Parker");
            IWorker eml_ar = new Employer(8, "Artur", "Arak");
            IWorker frl_j  = new Freelancer(10, "Jony", "Parker");
            IWorker eml_m  = new Employer(14, "Memphis", "Arak");
            IWorker frl_e  = new Freelancer(4, "Eden", "Parker");

            tl.AddMembers(new List <IWorker>()
            {
                tl, eml_a, frl_e, eml_ar, frl_j, frl_r, eml_m
            });

            foreach (var worker in tl.LeadMembers)
            {
                Console.WriteLine("{0} {1}, please, log your time.", worker.Name, worker.Surname);
                worker.LogTime();
            }

            tl.CalculateSalary(tl.LeadMembers);
            Console.Read();
        }
        public async Task <IActionResult> Edit(string id, [Bind("freelancerId,phoneNumber,education,id,englishProficiency,hourlyRate,title,professionalOverview,photo,legaID,rate,score,status")] Freelancer freelancer)
        {
            if (id != freelancer.freelancerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(freelancer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FreelancerExists(freelancer.freelancerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(freelancer));
        }
 public ActionResult ContactInfo(Freelancer freelancer)
 {
     if (Session["FreelancerId"] == null)
     {
         return(Redirect("~/Home/Index"));
     }
     try
     {
         int f_id   = Convert.ToInt32(Session["FreelancerId"]);
         var f_info = db.Freelancers.Where(f => f.FreelancerId == f_id)
                      .SingleOrDefault();
         if (f_info == null)
         {
             return(Redirect("~/Home/Index"));
         }
         f_info.Address = freelancer.Address;
         f_info.Phone   = freelancer.Phone;
         db.SaveChanges();
         return(Redirect("~/Settings/ContactInfo"));
     }
     catch (Exception)
     {
         return(Redirect("~/Settings/ContactInfo"));
     }
 }
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
            var signInManager = Context.GetOwinContext().Get<ApplicationSignInManager>();
            var user = new Freelancer()
            {
                Email = Email.Text,
                UserName = UserName.Text,
                FirstName = FirstName.Text,
                LastName = LastName.Text,
                Avatar = GlobalConstants.DefaultAvatar
            };

            IdentityResult result = manager.Create(user, Password.Text);

            if (result.Succeeded)
            {
                manager.AddToRole(user.Id, Role);

                signInManager.SignIn(user, isPersistent: false, rememberBrowser: false);
                Notifier.Success("Registration was successful!");
                IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
            }
            else
            {
                Notifier.Error(result.Errors.FirstOrDefault());
            }
        }
Пример #15
0
        public void deleteFreelancer(int phone)
        {
            Freelancer f = db.Freelancers.Where(i => i.Phone == phone).SingleOrDefault();

            db.Freelancers.Remove(f);
            db.SaveChanges();
        }
 public ActionResult ProfileIntroduction(Freelancer freelancer)
 {
     if (Session["FreelancerId"] == null)
     {
         return(Redirect("~/Home/Index"));
     }
     try
     {
         int f_id   = Convert.ToInt32(Session["FreelancerId"]);
         var f_info = db.Freelancers.Where(f => f.FreelancerId == f_id)
                      .SingleOrDefault();
         if (f_info == null)
         {
             return(Redirect("~/Home/Index"));
         }
         f_info.FreelancerTitle        = freelancer.FreelancerTitle;
         f_info.FreelancerName         = freelancer.FreelancerName;
         f_info.FreelancerIntroduction = freelancer.FreelancerIntroduction;
         db.SaveChanges();
         return(Redirect("~/Settings/ProfileIntroduction"));
     }
     catch (Exception)
     {
         return(Redirect("~/Settings/ProfileIntroduction"));
     }
 }
Пример #17
0
        public Freelancer Freelancer(int id)
        {
            Freelancer freelancer = null;

            string query = "SELECT * FROM freelancer WHERE StudentId = @id";

            using (MySqlCommand command = new MySqlCommand(query, new MySqlConnection(getConnectionString())))
            {
                command.Parameters.AddWithValue("@id", id);
                command.Connection.Open();
                command.CommandType = System.Data.CommandType.Text;

                using (MySqlDataReader reader = command.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            freelancer = new Freelancer(reader.GetInt32(0), reader.GetInt32(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5));
                        }
                    }
                    reader.Close();
                }
                //Close Connection
                command.Connection.Close();
            }
            return(freelancer);
        }
        public ActionResult F_Verify(Freelancer freelancer)
        {
            if (Session["FreelancerEmail"] == null || Session["RandomNumber"] == null)
            {
                return(Redirect("~/Accounts/SignIn"));
            }
            if (Convert.ToInt32(Session["RandomNumber"]) != freelancer.VerificationCode)
            {
                ViewBag.VerificationMsg = "You entered invalid verification code, please try again.";
                return(View());
            }
            //string email = Session["FreelancerEmail"].ToString();
            int freelancerId = Convert.ToInt32(Session["FreelancerId"]);

            try
            {
                var freelancer_info = db.Freelancers.SingleOrDefault(f => f.FreelancerId == freelancerId);
                if (freelancer_info == null)
                {
                    return(Redirect("~/Accounts/SignIn"));
                }
                freelancer_info.EmailVerified = 1;
                db.SaveChanges();
                return(Redirect("~/Freelancers/ProfileInfo"));
            }
            catch (Exception)
            {
                return(Redirect("~/Accounts/SignIn"));
            }
        }
        public async Task <FreelancerResponse> UpdateAsync(int id, Freelancer freelancer)
        {
            var existingFreelancer = await freelancerRepository.FindById(id);

            if (existingFreelancer == null)
            {
                return(new FreelancerResponse("Freelancer not found"));
            }

            existingFreelancer.Description = freelancer.Description;
            existingFreelancer.ImageUrl    = freelancer.ImageUrl;
            existingFreelancer.FirstName   = freelancer.FirstName;
            existingFreelancer.LastName    = freelancer.LastName;
            existingFreelancer.Specialty   = freelancer.Specialty;
            existingFreelancer.City        = freelancer.City;
            existingFreelancer.Description = freelancer.Description;

            try
            {
                freelancerRepository.Update(existingFreelancer);
                await unitOfWork.CompleteAsync();

                return(new FreelancerResponse(existingFreelancer));
            }
            catch (Exception ex)
            {
                return(new FreelancerResponse($"An error ocurred while updating the freelancer: {ex.Message}"));
            }
        }
Пример #20
0
        public ActionResult Edit([Bind(Include = "FreelancerId,VerifiedFlag")] Freelancer freelancer)
        {
            if (Session["AdminEmail"] == null || Session["AdminId"] == null)
            {
                return(Redirect("~/Home/Admin"));
            }
            if (freelancer.FreelancerId < 0)
            {
                return(RedirectToAction("Index"));
            }
            try
            {
                var result = db.Freelancers.SingleOrDefault(t => t.FreelancerId == freelancer.FreelancerId);
                result.VerifiedFlag = freelancer.VerifiedFlag;
                int rowaffect = db.SaveChanges();
                if (rowaffect > 0)
                {
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("Index"));
            }

            ViewBag.CityId = new SelectList(db.Cities, "CityId", "CityName", freelancer.CityId);
            ViewBag.FreelancerCategoryId = new SelectList(db.FreelancerCategories, "FreelancerCategoryId", "FreelancerCategoryName", freelancer.FreelancerCategoryId);
            return(View(freelancer));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("Name,Id")] Freelancer freelancer)
        {
            if (id != freelancer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(freelancer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FreelancerExists(freelancer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(freelancer));
        }
Пример #22
0
        /* Freelancer*/
        public bool postWork(Freelancer freelancer)
        {
            //if (!validRoomAd(room))
            //    return false;

            bool success = false;

            query = @"INSERT INTO freelancer(StudentId, Description, Image, Price, Work) values(@StudentId, @Description, @Image, @Price, @Work)";

            using (MySqlCommand command = new MySqlCommand(query, new MySqlConnection(getConnectionString())))
            {
                //General
                command.Parameters.AddWithValue("@StudentId", freelancer.StudentId);
                command.Parameters.AddWithValue("@Description", freelancer.Description);
                command.Parameters.AddWithValue("@Image", freelancer.Image);
                command.Parameters.AddWithValue("@Price", freelancer.Price);
                command.Parameters.AddWithValue("@Work", freelancer.Work);

                command.Connection.Open();
                command.CommandType = System.Data.CommandType.Text;
                command.ExecuteNonQuery();

                command.Connection.Close();

                success = true;
            }

            return(success);
        }
        public Freelancer freeMainAbilities(int freelancer_id, int cv_id)
        {
            var freelancer = (from free in pgfe.freelancer
                              join c in pgfe.cv on free.cv_id equals c.cv_id
                              where free.freelancer_id == freelancer_id
                              select new
            {
                free.freelancer_id,
                free.firstname,
                free.lastname,
                free.adress,
                free.phonenumber,
                free.email,
                free.PersonalLetter,
                c.drivers_license,
                c.cv_id,
                c.birthday,
                c.nationality,
            }).FirstOrDefault();
            Freelancer fl = new Freelancer()
            {
                MainAbilitiesList = GetMain_Abilities(cv_id)
            };

            return(fl);
        }
Пример #24
0
        public ActionResult DeleteConfirmed(int id)
        {
            Freelancer freelancer = db.Freelancer.Find(id);

            db.Freelancer.Remove(freelancer);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Freelancer     freelancer     = db.Freelancer.Find(id);
            core_abilities core_abilities = db.core_abilities.Find(id);

            db.core_abilities.Remove(core_abilities);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public IQueryable<Freelancer> UpdateProfileFreelancer(Freelancer updatedUser)
        {
            this.freelancers.Update(updatedUser);
            this.freelancers.SaveChanges();

            return this.freelancers
                .All()
                .Where(r => r.Id == updatedUser.Id);
        }
Пример #27
0
        public IActionResult Read(int id)

        {
            var resultado = new Freelancer();

            using (var data = new FreelancerData())
                resultado = data.Read(id);
            return(Ok(resultado));
        }
 public ActionResult Edit([Bind(Include = "Candidate_Id,Firstname,Lastname,Nationality,Address,Postalnumber,City,Birthdate,Cityofbirth,Email,Phonenumber")] Freelancer freelancer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(freelancer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(freelancer));
 }
Пример #29
0
        public void FreelancerEarnMoneyAreEqual()
        {
            string     constResult = "Получаем оплату за выполненный заказ";
            Programmer programmer  = new Freelancer(null);
            string     result;

            result = programmer.EarnMoney();

            Assert.AreEqual(constResult, result);
        }
        // GET: FreelancerBio
        public ActionResult Bio(int id)
        {
            Freelancer freelancer = db.Freelancers.Find(id);
            User       userID     = new WedSpread.Models.User();

            userID            = GetUsers();
            freelancer.UserID = userID.UserID;

            return(View(freelancer));
        }
Пример #31
0
        public void AddFreelancer(string firstName, string lastName)
        {
            var freelancer = new Freelancer()
            {
                FirstName = firstName, LastName = lastName
            };

            _context.Freelancer.Add(freelancer);
            _context.SaveChanges();
        }
Пример #32
0
 public ActionResult Edit([Bind(Include = "freelancer_Id,Firstname,Lastname,Username,Feelancer_Password,Address,Phonenumber,Email,Birthday,BirthCity,Nationality,Drivers_license,Profile_text")] Freelancer freelancer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(freelancer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(freelancer));
 }