Beispiel #1
0
        public ActionResult Edit(resource r)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:18080");

            ResourceViewModels res = new ResourceViewModels();

            res.userId        = r.userId;
            res.nom           = r.nom;
            res.prenom        = r.prenom;
            res.email         = r.email;
            res.dateNaissance = r.dateNaissance;
            res.password      = r.password;
            res.competance    = r.competance;
            res.resourceType  = r.resourceType;
            res.seniority     = r.seniority;
            res.resourceState = "Available";
            res.role          = "Ressource";
            Adresse adresse = new Adresse();

            adresse.codePostal = "2222";
            adresse.pays       = "Tunis";
            adresse.rue        = "aa";
            adresse.ville      = "aa";
            res.adresse        = adresse;

            client.PutAsJsonAsync <ResourceViewModels>("http://localhost:18080/MapLevio-web/rest/Resource/" + res.userId.ToString(), res).Result.EnsureSuccessStatusCode();


            return(RedirectToAction("ListeResource"));
        }
Beispiel #2
0
        // GET: Resources
        public ActionResult Index()
        {
            SE_ProjectEntities        db    = new SE_ProjectEntities();
            List <ResourceViewModels> model = new List <ResourceViewModels>();

            foreach (MaterialResource m in db.MaterialResources)
            {
                if (m.Classid == DLSInterface.ClassEntered)
                {
                    ResourceViewModels s = new ResourceViewModels();
                    s.name = m.Name;
                    s.id   = m.id;
                    model.Add(s);
                }
            }
            return(View(model));
        }
Beispiel #3
0
        public ActionResult Create(resource r, HttpPostedFileBase file)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:18080");
            ResourceViewModels res = new ResourceViewModels();

            res.nom           = r.nom;
            res.prenom        = r.prenom;
            res.email         = r.email;
            res.dateNaissance = r.dateNaissance;
            res.password      = r.password;
            res.archivé       = false;
            res.competance    = r.competance;
            res.role          = "Ressource";
            res.resourceState = "Available";
            res.resourceType  = r.resourceType;
            res.seniority     = r.seniority;
            Adresse adresse = new Adresse();

            adresse.codePostal = r.codePostal;
            adresse.pays       = r.pays;
            adresse.rue        = r.rue;
            adresse.ville      = r.ville;
            res.adresse        = adresse;
            var fileName = "";

            if (file.ContentLength > 0)
            {
                fileName = Path.GetFileName(file.FileName);
                var path = Path.Combine(Server.MapPath("~/Content/Upload"), file.FileName);
                file.SaveAs(path);
            }
            res.image = file.FileName;

            client.PostAsJsonAsync <ResourceViewModels>("http://localhost:18080/MapLevio-web/rest/Resource/addresource", res).ContinueWith((postTask) => postTask.Result.EnsureSuccessStatusCode());
            return(RedirectToAction("ListeResource"));
        }