示例#1
0
        public async Task <IActionResult> AddLogement(LogementExtViewModel model)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = null;


                List <LNDocuments> emp = new List <LNDocuments>();
                if (model.FileP != null && model.FileP.Count > 0)
                {
                    // Loop thru each selected file
                    foreach (IFormFile photo in model.FileP)
                    {
                        LNDocuments employe = new LNDocuments();
                        // The file must be uploaded to the images folder in wwwroot
                        // To get the path of the wwwroot folder we are using the injected
                        // IHostingEnvironment service provided by ASP.NET Core
                        string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "Files");
                        // To make sure the file name is unique we are appending a new
                        // GUID value and and an underscore to the file name
                        uniqueFileName = Guid.NewGuid().ToString() + "_" + photo.FileName;
                        string filePath = Path.Combine(uploadsFolder, uniqueFileName);
                        // Use CopyTo() method provided by IFormFile interface to
                        // copy the file to wwwroot/images folder
                        photo.CopyTo(new FileStream(filePath, FileMode.Create));
                        employe.Filepath = uniqueFileName;
                        emp.Add(employe);
                    }
                }



                Fournisseur    f = (Fournisseur)userManager.GetUserAsync(User).Result;
                ServiceLogment serviceLogment = new ServiceLogment
                {
                    Adresse     = model.Adresse,
                    Description = model.Description,
                    PrixParNuit = model.PrixParNuit,
                    Titre       = model.Titre,
                    Category    = model.Category
                    ,

                    Type        = model.Type,
                    Fournisseur = f,
                    Documents   = emp
                };



                await logementService.Ajout(serviceLogment);

                TempData["id"] = JsonConvert.SerializeObject(serviceLogment.Id);

                return(RedirectToAction("DetailsLogement", "Service"));
            }


            return(View(model));
        }
示例#2
0
        public IActionResult DetailsLogement(int id)

        {
            if (id == 0)
            {
                ViewData["id"] = JsonConvert.DeserializeObject <int>((string)TempData["id"]);
                TempData.Keep("id");

                id = (int)ViewData["id"];
            }


            ViewBag.user = userManager.GetUserAsync(User).Result;
            // ViewBag.Best = ExperienceService.BestExperience();

            ServiceLogment logment = logementService.GetById(id).Result;

            return(View(logment));
        }
示例#3
0
 public Task Update(ServiceLogment logement)
 {
     return(GenericRepo.PutAsync(logement.Id, logement));
 }
示例#4
0
        public async Task <ServiceLogment> GetById(int id)
        {
            ServiceLogment l = await LogementRepo.GetlogementDetailsAsync(id);

            return(l);
        }
示例#5
0
 public Task Delete(ServiceLogment logement)
 {
     return(GenericRepo.DeleteAsync(logement.Id));
 }
示例#6
0
 public Task Ajout(ServiceLogment logement)
 {
     return(GenericRepo.InsertAsync(logement));
 }