Пример #1
0
        public async Task <ActionResult> Create(
            [Bind(Include = "CompanyName, CityName, FromDate, ToDate, ProExpDescription, ProExpName, ProExpPosition")] CreateProExpViewModel proExpViewModel)
        {
            if (ModelState.IsValid)
            {
                var proExpToAdd = new ProExpModel
                {
                    CompanyName = proExpViewModel.CompanyName,
                    CityName    = proExpViewModel.CityName,
                    FromDate    = proExpViewModel.FromDate,
                    ToDate      = proExpViewModel.ToDate,
                    ProfileId   = _userModel.Id,
                    ExperienceDescriptionModel = new List <ExperienceDescriptionModel>()
                };

                var expProDesc = new ExperienceDescriptionModel
                {
                    Description  = proExpViewModel.ProExpDescription,
                    PositionDesc = proExpViewModel.ProExpPosition,
                    Name         = proExpViewModel.ProExpName
                };

                proExpToAdd.ExperienceDescriptionModel.Add(expProDesc);


                await _proExpService.CreateAsync(proExpToAdd);

                return(RedirectToAction("Index"));
            }

            return(View(proExpViewModel));
        }
Пример #2
0
        public async Task <ActionResult> Create([Bind(Include = "CompanyName, CityName, FromDate, ToDate")] CreateProExpViewModel proExpViewModel)
        {
            if (ModelState.IsValid)
            {
                var proExpToAdd = new ProExpModel
                {
                    CompanyName = proExpViewModel.CompanyName,
                    CityName    = proExpViewModel.CityName,
                    FromDate    = proExpViewModel.FromDate,
                    ToDate      = proExpViewModel.ToDate,
                    ProfileId   = _userModel.Id
                };

                await _proExpService.CreateAsync(proExpToAdd);

                return(RedirectToAction("Index"));
            }

            return(View(proExpViewModel));
        }