public ActionResult NewProposition(string id, [FromBody] Offre offre) { try { var proposition = new Proposition { Id = offre.Id, Offre = offre }; var entrepriseCollection = new EntrepriseCollection(); var entreprise = entrepriseCollection.GetItems(e => e.Id == id).FirstOrDefault(); if (entreprise == null) { return(StatusCode(500, "Internal Server Error: Entreprise not found")); } if (entreprise.Propositions == null) { entreprise.Propositions = new List <Offre>(); } ((List <Offre>)(entreprise.Propositions)).Add(offre); entrepriseCollection.UpdateItem(entreprise.Id, entreprise); var propositionCollection = new PropositionCollection(); propositionCollection.NewItems(proposition); return(Ok("Propositions posté avec success")); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public ActionResult <string> UploadFile(string id, string type) { try { if (type != "profil") { throw new Exception("File type not supported for this URL"); } var file = Request.Form.Files[0]; var ext = file.FileName.Split('.').Last(); var entrepriseCollection = new EntrepriseCollection(); var entreprise = entrepriseCollection.GetItems(e => e.Id == id).FirstOrDefault(); if (entreprise == null) { throw new Exception("Entreprise not found"); } StorageAzureManager storage = new StorageAzureManager("profilsentreprises"); var path = storage.UpladFile($"entreprises/{id}.{ext}", file.OpenReadStream(), file.ContentType).GetAwaiter().GetResult(); entreprise.EmployeurIdentite.ImageProfil = path; entrepriseCollection.UpdateItem(id, entreprise); //var stream = new Stream(file) return(Ok(path)); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public ActionResult <string> UpdateEntreprise(string id, int type, [FromBody] EmployeurIdentite employeur) { try { string dataResult = ""; var entrepriseCollection = new EntrepriseCollection(); PublicationCollection publicationCollection = new PublicationCollection(); var employeurIdentite = entrepriseCollection.GetItems(e => e.Id == id).FirstOrDefault(); if (type == 1) { employeurIdentite.EmployeurIdentite.Nom = employeur.Nom; employeurIdentite.EmployeurIdentite.Adresse = employeur.Adresse; employeurIdentite.EmployeurIdentite.IdNational = employeur.IdNational; entrepriseCollection.UpdateItem(id, employeurIdentite); dataResult = "Identité modifié avec succès"; } else if (type == 2) { employeurIdentite.EmployeurIdentite.MotDePasse = employeur.MotDePasse; entrepriseCollection.UpdateItem(id, employeurIdentite); dataResult = "Mot de passe modifié avec succès"; } else if (type == 3) { employeurIdentite.EmployeurIdentite.AboutEntreprise = employeur.AboutEntreprise; employeurIdentite.EmployeurIdentite.Domaines = employeur.Domaines; entrepriseCollection.UpdateItem(id, employeurIdentite); dataResult = "Les details modifié avec succès"; } else { throw new Exception("Modifications non pris en charge"); } return(StatusCode(200, dataResult)); } catch (Exception) { throw; } }
public ActionResult <string> ConfirmerLeCompte(string id) { try { var entrepriseCollection = new EntrepriseCollection(); var entreprise = entrepriseCollection.GetItems(e => e.Id == id).FirstOrDefault(); if (entreprise == null) { throw new Exception("Erreur: Utilisateur non trouvé"); } else { entreprise.EmployeurIdentite.IsActive = true; entrepriseCollection.UpdateItem(id, entreprise); return(StatusCode(200, "Compte confirmé")); } } catch (Exception e) { return(StatusCode(500, $"Erreur: {e.Message}")); } }