public async Task <IActionResult> UnBan([FromBody] string username) { try { if (username == null) { return(NotFound()); } AspNetUser user = _context.AspNetUsers.Where(d => d.UserName.Equals(username)).Single(); if (user == null) { return(NotFound()); } user.LockoutEnd = null; _context.Entry(user).State = EntityState.Modified; await _context.SaveChangesAsync(); return(Ok()); } catch (Exception) { return(BadRequest()); } }
public async Task <IActionResult> PutContactRequest(short id, ContactRequest contactRequest) { if (id != contactRequest.RequestId) { return(BadRequest()); } _context.Entry(contactRequest).State = EntityState.Modified; try { _context.SaveChanges(); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactRequestExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutHairSize(short id, HairSize hairSize) { if (id != hairSize.HairSizeId) { return(BadRequest()); } _context.Entry(hairSize).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HairSizeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProfil(short id, Profil profil) { if (id != profil.ProfilId) { return(BadRequest()); } _context.Entry(profil).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProfilExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutReligion(short id, Religion religion) { if (id != religion.ReligionId) { return(BadRequest()); } _context.Entry(religion).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReligionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutSex(short id, Sex sex) { if (id != sex.SexeId) { return(BadRequest()); } _context.Entry(sex).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SexExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutBotCommand(short id, BotCommand botCommand) { if (id != botCommand.Id) { return(BadRequest()); } _context.Entry(botCommand).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BotCommandExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutContactRequest(short id, ContactRequest contactRequest) { if (id != contactRequest.RequestId) { return(BadRequest()); } var detailOldContactRequest = _context.ContactRequests.Where(x => x.RequestId == contactRequest.RequestId).SingleOrDefault(); contactRequest.Id = detailOldContactRequest.Id; contactRequest.RequestDate = detailOldContactRequest.RequestDate; _context.Entry(contactRequest).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactRequestExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutInsult(int id, Insult insult) { if (id != insult.InsultId) { return(BadRequest()); } _context.Entry(insult).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InsultExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAnswer(short id, Answer answer) { if (id != answer.AnswerId) { return(BadRequest()); } _context.Entry(answer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnswerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> BanUser(string id) { if (id != null) { AspNetUser user = await _context.AspNetUsers.Where(u => u.UserName == id).FirstOrDefaultAsync(); user.LockoutEnd = new DateTimeOffset(new DateTime(2400, 05, 03)); _context.Entry(user).State = EntityState.Modified; await _context.SaveChangesAsync(); return(StatusCode(200)); } else { return(StatusCode(404)); } }
public async Task <IActionResult> PutAspNetUser(AspNetUser aspNetUser) { _context.Entry(aspNetUser).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AspNetUserExists(aspNetUser.Id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAd(short id, AdPost adPost) { if (id != adPost.Id) { return(BadRequest()); } string folder = "Ads"; AdInput ad = new AdInput(); ad.Id = adPost.Id; ad.Titre = adPost.Titre; ad.Description = adPost.Description; ad.Link = adPost.Link; byte[] data = Convert.FromBase64String(adPost.file); var stream = new MemoryStream(data); IFormFile file = new FormFile(stream, 0, data.Length, adPost.name, adPost.fileName) { Headers = new HeaderDictionary(), ContentType = adPost.ContentType, ContentDisposition = adPost.ContentDisposition }; ad.file = file; if (ad.file.Length > 0) { if (!Directory.Exists(Path.Combine(_environnement.WebRootPath, folder))) { Directory.CreateDirectory(Path.Combine(_environnement.WebRootPath, folder)); } string filename = "_ad" + DateTime.Now.ToString("_yyyy-MM-dd_HH-mm-ss_") + ad.file.FileName; using (FileStream fileStream = System.IO.File.Create(Path.Combine(_environnement.WebRootPath, folder, filename))) { ad.file.CopyTo(fileStream); fileStream.Flush(); _context.Entry(new Ad { Id = ad.Id, Titre = ad.Titre, Description = ad.Description, AdView = folder + "/" + filename, Link = ad.Link }).State = EntityState.Modified; } } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }