Exemple #1
0
        public VacancyViewModel(DAL.Vacancy vacancy, Uri webSiteUrl, string fallbackImage = null)
        {
            _websiteUrl = webSiteUrl;
            var fallbackImageUrl = string.IsNullOrWhiteSpace(fallbackImage) ? null : new Uri(fallbackImage);

            Id          = vacancy.Id;
            Title       = vacancy.Title;
            Image       = string.IsNullOrEmpty(vacancy.Image) ? fallbackImageUrl : new Uri(vacancy.Image);
            Description = vacancy.Description;
            Content     = vacancy.Content;
            Contact     = vacancy.Contact;
            Active      = vacancy.Active == 1;
            Date        = vacancy.Date;
            Url         = string.IsNullOrWhiteSpace(vacancy.Url) ? null : new Uri(vacancy.Url);
            Category    = new CategoryViewModel();
            Company     = vacancy.Company;
            ViewsCount  = vacancy.Views;
            Location    = vacancy.Location;

            if (vacancy.Category != null)
            {
                Category.Id   = vacancy.Category.Id;
                Category.Name = vacancy.Category.Name;
            }
        }
Exemple #2
0
        public VacancyViewModel(DAL.Vacancy vacancy, string webSiteUrl, string fallbackImage = null)
        {
            _websiteUrl = webSiteUrl;

            Id          = vacancy.Id;
            Title       = vacancy.Title;
            Image       = vacancy.Image ?? fallbackImage;
            Description = vacancy.Description;
            Content     = vacancy.Content;
            Contact     = vacancy.Contact;
            Active      = vacancy.Active;
            Date        = vacancy.Date;
            Url         = string.IsNullOrWhiteSpace(vacancy.Url) ? null : new Uri(vacancy.Url);
            Category    = new CategoryViewModel();
            Company     = vacancy.Company;
            ViewsCount  = vacancy.Views;
            Location    = vacancy.Location;

            //ViewsCount = new Random((int)DateTime.Now.Ticks).Next(10, 915);

            if (vacancy.Category != null)
            {
                Category.Id   = vacancy.Category.Id;
                Category.Name = vacancy.Category.Name;
            }
        }
Exemple #3
0
        public VacancyViewModel(DAL.Vacancy vacancy, string webSiteUrl, string fallbackImage = null)
        {
            _websiteUrl = webSiteUrl;
            Id          = vacancy.Id;
            Title       = vacancy.Title;
            Image       = vacancy.Image ?? fallbackImage;
            Description = vacancy.Description;
            Content     = vacancy.Content;
            Contact     = vacancy.Contact;
            Active      = vacancy.Active;
            Date        = vacancy.Date;
            Url         = string.IsNullOrWhiteSpace(vacancy.Url) ? null : new Uri(vacancy.Url);
            Category    = new CategoryViewModel();

            if (vacancy.Category != null)
            {
                Category.Id   = vacancy.Category.Id;
                Category.Name = vacancy.Category.Name;
            }
        }
Exemple #4
0
        public async Task <IActionResult> AddVacancy(NewVacancyRequest request)
        {
            var user = _userManager.GetBySecretKey(request.Key);

            if (user == null)
            {
                return(Forbid());
            }

            var vacancy = new DAL.Vacancy
            {
                Title       = request.Title,
                Description = request.Description,
                Contact     = request.Contact,
                UserId      = user.Id,
                CategoryId  = request.CategoryId,
                Date        = DateTime.Now,
                Active      = true,
                Content     = request.Content,
                Image       = null,
                Url         = null,
            };

            vacancy = await _vacancyManager.Save(vacancy);

            if (vacancy != null)
            {
                var model = new VacancyViewModel(vacancy, _settings.WebSiteUrl);

                foreach (var crossPostManager in _crossPostManagers)
                {
                    await crossPostManager.Send(request.CategoryId, request.Comment, model.ShareUrl);
                }

                return(Created(new Uri(model.ShareUrl), model));
            }

            return(BadRequest());
        }