Example #1
0
        public virtual async Task <ActionResult> Create(AddWorkExperienceViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                await _workExperienceService.FillAddViewModel(viewModel, IranCitiesPath);

                return(new JsonNetResult
                {
                    Data = new
                    {
                        success = false,
                        View = this.RenderPartialViewToString(MVC.WorkExperience.Views._Create, viewModel)
                    }
                });
            }
            var newWork = await _workExperienceService.Create(viewModel);

            return(new JsonNetResult
            {
                Data = new
                {
                    success = true,
                    View = this.RenderPartialViewToString(MVC.WorkExperience.Views._WorkExperienceItem, newWork)
                }
            });
        }
Example #2
0
        public async Task <WorkExperienceViewModel> Create(AddWorkExperienceViewModel viewModel)
        {
            var workExperience = _mappingEngine.Map <WorkExperience>(viewModel);

            _workExperiences.Add(workExperience);
            await _unitOfWork.SaveChangesAsync();

            return(await GetWorkExperienceViewModel(workExperience.Id));
        }
Example #3
0
 public async Task FillAddViewModel(AddWorkExperienceViewModel viewModel, string path)
 {
     viewModel.States = _stateService.GetAsSelectListItemAsync(viewModel.State, path);
     viewModel.Cities = _cityService.GetAsSelectListByStateNameAsync(viewModel.State, viewModel.City, path);
 }