Ejemplo n.º 1
0
        public void Execute(CategoryDto request)
        {
            _validator.ValidateAndThrow(request);
            var newCategory = new Category
            {
                CategoryName = request.CategoryName
            };

            _context.Add(newCategory);
            _context.SaveChanges();
        }
Ejemplo n.º 2
0
        public void Execute(LocationDto request)
        {
            validations.ValidateAndThrow(request);

            var location = new Location
            {
                CityName = request.CityName
            };

            _context.Add(location);

            _context.SaveChanges();
        }
Ejemplo n.º 3
0
        public void Execute(RegisterDto request)
        {
            _validation.ValidateAndThrow(request);
            var newFileName = "basicavatar.jpg";

            if (request.Avatar != null)
            {
                var guid      = Guid.NewGuid();
                var extension = Path.GetExtension(request.Avatar.FileName);
                newFileName = guid + extension;
                var path = Path.Combine("wwwroot", "images", newFileName);
                using (var fileStream = new FileStream(path, FileMode.Create))
                {
                    request.Avatar.CopyTo(fileStream);
                }
            }


            var newFileNameCv = "";

            if (request.Cv != null)
            {
                var guidCv = Guid.NewGuid();
                newFileNameCv = guidCv + request.Cv.FileName;
                var pathCv = Path.Combine("wwwroot", "cv", newFileNameCv);
                using (var fileStreamCv = new FileStream(pathCv, FileMode.Create))
                {
                    request.Cv.CopyTo(fileStreamCv);
                }
            }


            var registration = new User
            {
                Username   = request.Username,
                Password   = request.Password,
                Name       = request.Name,
                Surname    = request.Surname,
                Email      = request.Email,
                Phone      = request.Phone,
                Birthdate  = request.Birthdate,
                CvPath     = newFileNameCv,
                AvatarPath = newFileName,
                AvatarAlt  = request.AvatarAlt,
                RoleId     = request.RoleId
            };

            _context.Add(registration);
            _context.SaveChanges();
        }
Ejemplo n.º 4
0
        public void Execute(JobvacanciesDto request)
        {
            _validator.ValidateAndThrow(request);
            var newJobVacancie = new JobUser
            {
                JobId          = request.JobId,
                UserId         = _actor.Id,
                Status         = 0,
                JobName        = request.JobName,
                JobDescription = request.JobDescription
            };

            _context.Add(newJobVacancie);
            _context.SaveChanges();
        }
Ejemplo n.º 5
0
        public void Execute(JobDto request)
        {
            _validation.ValidateAndThrow(request);

            var job = new Job
            {
                JobName             = request.JobName,
                JobResponsibilities = request.JobResponsibilities,
                JobRequirments      = request.JobRequirments,
                JobDescription      = request.JobDescription,
                WorktimeId          = (Worktime)request.WorktimeId,
                WorktimeDescription = request.WorktimeDescription,
                PaymentId           = (Payment)request.PaymentId,
                PaymentDescription  = request.PaymentDescription,
                EndDate             = request.EndDate,
                IsFeatured          = request.IsFeatured,
                IsPremium           = request.IsPremium
            };

            foreach (var category in request.Categories)
            {
                job.JobCategories.Add(new JobCategory {
                    CategoryId = category.Id
                });
            }

            foreach (var location in request.Locations)
            {
                job.JobLocations.Add(new JobLocation
                {
                    LocationId       = location.Id,
                    DetailedLocation = location.DetailedLocation
                });
            }

            _context.Add(job);
            _context.SaveChanges();
        }