public IActionResult Get(int id)
        {
            var entity = _experienceService.GetById(id);
            var model  = entity.ToModel();

            //locals
            AddLocales(_languageWebApi, model.Locales, (locale, languageId) =>
            {
                locale.Name     = entity.GetLocalized(x => x.Name, languageId, false, false);
                locale.Period   = entity.GetLocalized(x => x.Period, languageId, false, false);
                locale.Function = entity.GetLocalized(x => x.Function, languageId, false, false);
                locale.Tasks    = entity.GetLocalized(x => x.Tasks, languageId, false, false);
            });

            return(Ok(model));
        }
Exemple #2
0
 public IActionResult Update(int id)
 {
     return(View(new ExperienceUpdateViewModel
     {
         Experience = _experienceService.GetById(id)
     }));
 }
        public async Task <IActionResult> ExperienceEdit(ExperienceCreateUpdateModel experienceModel, int[] selectedCategoryIds, IFormFile file)
        {
            if (ModelState.IsValid)
            {
                var experienceToBeEdited = _ExperienceService.GetById(experienceModel.ExperienceId);

                if (experienceToBeEdited != null)
                {
                    experienceToBeEdited.Name  = experienceModel.Name;
                    experienceToBeEdited.Title = experienceModel.Title;
                    experienceToBeEdited.Body  = experienceModel.Body;
                    if (experienceModel.LocationChoiceId != null)
                    {
                        experienceToBeEdited.LocationId = experienceModel.LocationChoiceId;
                    }


                    if (file != null)
                    {
                        var extention  = Path.GetExtension(file.FileName);
                        var randomName = string.Format($"{Guid.NewGuid()}{extention}");
                        experienceToBeEdited.ImageUrl = randomName;
                        var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot//img", randomName);

                        using (var stream = new FileStream(path, FileMode.Create))
                        {
                            await file.CopyToAsync(stream);
                        }
                    }



                    _ExperienceService.Update(experienceToBeEdited, selectedCategoryIds);

                    return(Redirect("/social/experiencedetails/" + experienceModel.ExperienceId));
                }
                return(NotFound());
            }
            experienceModel.ExperienceEditModelStateInvalid = true;

            return(View("experiencedetails", experienceModel));
        }
Exemple #4
0
        public ActionResult DeleteExperience(int id, int ExperienceId)
        {
            Candidate c = candidateService.GetById(id);

            for (int i = 0; i < c.Experiences.Count; i++)
            {
                if (c.Experiences.ElementAt(i).ExperienceId == ExperienceId)
                {
                    c.Experiences.Remove(c.Experiences.ElementAt(i));
                    break;
                }
            }
            candidateService.Update(c);
            candidateService.Commit();
            Experience e = experienceService.GetById(ExperienceId);

            experienceService.Delete(e);
            experienceService.Commit();
            return(RedirectToAction("Details", new { id }));
        }
        //[Authorize(Policy = "CreateExperiencePolicy")]
        public async Task <IActionResult> CreateExperience(ExperienceViewModel model)
        {
            //ViewData["Message"] = JsonConvert.DeserializeObject<List<Activite>>((string)TempData.Peek("Message"));
            //TempData.Keep("Message");
            //Activites = (ICollection<Activite>)ViewData["Message"];
            if (ModelState.IsValid)
            {
                string     id         = userManager.GetUserId(User);
                Experience experience = new Experience
                {
                    Titre          = model.Titre,
                    Lieu           = model.Lieu,
                    TypeExperience = model.TypeExperience,
                    dateDebut      = model.dateDebut,
                    dateFin        = model.dateFin,
                    Saison         = model.Saison,
                    NbPlaces       = model.NbPlaces,
                    tarif          = model.tarif,
                    Activites      = new Collection <Activite>(),
                    CommerçantId   = id
                };
                //foreach (var item in Activites)
                //{

                //    await ActiviteService.Ajout(item);

                //}

                var result = await ExperienceService.InsertExperience(experience);

                Experience experience1 = await ExperienceService.GetById((int)result);

                TempData["experience"] = JsonConvert.SerializeObject(experience1);
                System.Diagnostics.Debug.WriteLine("idezeeeeeeeeeeee est" + experience1.ExperienceId);
                TempData["exp"] = JsonConvert.SerializeObject(model);
                ViewData["exp"] = JsonConvert.DeserializeObject <ExperienceViewModel>((string)TempData.Peek("exp"));
                return(View("CreateActivite"));
            }


            return(View(model));
        }
 public IActionResult EditExperience(int experienceId)
 {
     ViewBag.resumepages = new SelectList(_resumepageService.GetAll(), "ResumepageId", "ResumepageTitle");
     return(View(_experienceService.GetById(experienceId)));
 }