public IHttpActionResult PutDemande(int id, Demande demande) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != demande.ID) { return(BadRequest()); } db.Entry(demande).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DemandeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> Register(RegisterBindingModel Model) { //var httpRequest = HttpContext.Current.Request; var user = new ApplicationUser() { UserName = Model.Email, Email = Model.Email }; IdentityResult result = await UserManager.CreateAsync(user, Model.Password); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!result.Succeeded) { return(GetErrorResult(result)); } //string imageName = null; // Upload Image //HttpPostedFile postedFile = Model.File; ////Create custom filename //imageName = new String(Path.GetFileNameWithoutExtension(postedFile.FileName).Take(10).ToArray()).Replace(" ", "-"); //imageName = imageName + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(postedFile.FileName); //var filePath = HttpContext.Current.Server.MapPath("~/Image/UsersImg/" + imageName); //postedFile.SaveAs(filePath); // Save to DB TourismeEntities context = new TourismeEntities(); var getId = context.AspNetUsers.FirstOrDefault(p => p.Email == Model.Email); Client registerInfo = new Client(); registerInfo.User_id = getId.Id; registerInfo.Client_Nom = Model.Name; registerInfo.Client_Prenom = Model.LastName; registerInfo.Email = Model.Email; context.Clients.Add(registerInfo); context.SaveChanges(); //CreatedAtRoute("DefaultApi", new { id = registerInfo.Id }, registerInfo); //return CreatedAtRoute("DefaultApi", new { id = allu.Id }, allu); return(Ok()); }