private void EndDateParser(ExperienceCreateInputModel input, Experience entity)
 {
     if (input.EndDate != null)
     {
         entity.EndDate = input.EndDate?.ToUniversalTime();
     }
     else
     {
         entity.EndDate = DateTime.UtcNow;
     }
 }
        public async Task <ActionResult> Post(ExperienceCreateInputModel input)
        {
            // var userId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var user = await this.userManager.GetUserAsync(this.User);

            var inputId = await this.experiencesService.CreateAsync(input, user.Id);

            var model = await this.experiencesService.GetByIdAsync <ExperienceExportModel>(inputId);

            return(this.CreatedAtAction(nameof(this.GetById), new { id = model.Id }, model));
        }
        private void InstanceBuilder(ExperienceCreateInputModel input, Experience entity, string userId)
        {
            entity.Url           = input.Url.Trim();
            entity.Logo          = input.Logo.Trim();
            entity.Company       = input.Company.Trim();
            entity.Job           = input.Job;
            entity.StartDate     = input.StartDate.ToUniversalTime();
            entity.IconClassName = input.IconClassName.Trim();
            entity.Details       = input.Details.Trim();
            entity.UserId        = userId;

            this.EndDateParser(input, entity);
        }
        public async Task <int> CreateAsync(ExperienceCreateInputModel input, string userId)
        {
            // var userEntity = this.usersRepository.AllAsNoTracking()
            //   .FirstOrDefault(x => x.UserName == articleInputModel.UserId);
            //// take the user and record its id in the article, product, conformity, etc.
            var entity = new Experience();

            this.InstanceBuilder(input, entity, userId);

            await this.experiencesRepository.AddAsync(entity);

            await this.experiencesRepository.SaveChangesAsync();

            return(entity.Id);
        }
示例#5
0
        public async Task <IActionResult> Create(ExperienceCreateInputModel input)
        {
            var defaultCvId = _cvService.GetId();

            if (!ModelState.IsValid)
            {
                return(View(input));
            }

            try
            {
                await _experienceService.CreateAsync(input, defaultCvId);
            }
            catch (Exception e)
            {
                _logger.LogError(e, "An exception occured during new experience record creation.");
                return(RedirectToAction("Error", "Home"));
            }

            return(RedirectToAction("Index", "Home"));
        }
示例#6
0
        public IActionResult Create()
        {
            var viewModel = new ExperienceCreateInputModel();

            return(View(viewModel));
        }