public IHttpActionResult Delete(int id) { using (_classService) { _classService.Delete(id); } return(Ok()); }
public IActionResult Delete(int Id) { var data = _classService.Delete(Id); if (data > 0) { return(Ok(data)); } return(BadRequest("Failed")); }
public IHttpActionResult Delete(int id) { try { _classService.Delete(id); return(Ok(true)); } catch (Exception ex) { return(Ok(ex)); } }
public IActionResult Delete([FromBody] string id) { try { var response = _classService.Delete(id); return(Ok(response)); } catch (Exception e) { _logExceptionService.LogException(e); return(BadRequest(e.Message)); } }
public void DeleteClass_WhereClassExists_ReturnsOkResponse([Values(1, 2, 3)] int idOfClassToBeDeleted) { //Arrange Mock.Arrange(() => _classService.Delete(idOfClassToBeDeleted)).OccursOnce(); var classController = new ClassController(_classService); //Act var actual = classController.Delete(idOfClassToBeDeleted) as OkResult; //Assert Mock.Assert(_classService); Assert.That(actual, Is.TypeOf <OkResult>()); }
public async Task <object> Delete(ClassById request) { var response = new BaseResponse(); Expression <Func <Class, bool> > keySelector = x => x.Id == request.Id; var result = await _classService.Delete(keySelector : keySelector); response.Success = true; response.Message = $"Delete class with id {request.Id} success"; response.StatusCode = (int)HttpStatusCode.OK; response.Results = result.ConvertTo <ClassDto>(); return(response); }
public async Task <IActionResult> ClassRoomDelete( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "class-room/{classRoomId}/delete")] HttpRequest req, string classRoomId) { var validateStatus = base.AuthorizationStatus(req); if (validateStatus != System.Net.HttpStatusCode.Accepted) { return(new BadRequestObjectResult(validateStatus)); } await _classService.Delete(classRoomId); return(new OkObjectResult(new { message = "Delete class room successful." })); }
public IActionResult Delete(int id) { try { Log.Information($"Attempting to delete class: {id}"); _classService.Delete(id); Log.Information($"Successfully Deleted class {id}"); return(Ok(id)); } catch (AppException ex) { return(BadRequest(ex.Message)); } }
public async Task <IActionResult> Delete(int id) { if (!ModelState.IsValid) { return(BadRequest()); } if (!(await _classService.Delete(id))) { return(StatusCode(500)); } return(Ok()); }
public ActionResult Delete(int ID, Class _class) { try { iclassservice.Delete(ID, _class); return(RedirectToAction("Index")); } catch (Exception exception) { ClassController.log.Error((object)(" Create -" + (object)exception)); return(View()); } }
public async Task <ActionResult> Delete(Guid id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { return(Ok(await _service.Delete(id))); } catch (ArgumentException e) { return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message)); } }
// DELETE: api/Classes/5 public HttpResponseMessage DeleteClass(int id) { var message = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Bad Request"); if (string.IsNullOrWhiteSpace(id.ToString())) { message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid Id"); } else { var result = _iClassService.Delete(id.ToString()); if (result) { message = Request.CreateResponse(HttpStatusCode.OK); } } return(message); }
public async Task <object> DeleteClass(int id) { try { if (await this.CheckPermissionToDeleteClass(id)) { Response response = await _classService.Delete(id); return(response); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public ActionResult Delete(List <int> ids) { try { foreach (var id in ids) { ClassDTO classDTO = new ClassDTO(); classDTO.Id = id; _classService.Delete(classDTO); } } catch (Exception) { throw; } TempData["Statu"] = "ok"; return(RedirectToAction("index")); }
public ActionResult Delete(ClassViewModel viewModel) { if (ModelState.IsValid) { var result = _classService.Delete(viewModel.ClassId); if (result.Success) { var bodySubject = "Web portal changes - Class Delete"; SendMailToAdmin(result.Results.FirstOrDefault().Message, bodySubject); Success(result.Results.FirstOrDefault().Message); ModelState.Clear(); } else { _logger.Warn(result.Results.FirstOrDefault().Message); Warning(result.Results.FirstOrDefault().Message, true); } } return(RedirectToAction("Index")); }
public IHttpActionResult Delete(Guid id) { _classService.Delete(id); return(Ok()); }
public async Task <IResultModel> Delete([BindRequired] Guid id) { return(await _service.Delete(id)); }
public bool Delete([FromRoute] Guid ClassId) { return(ClassService.Delete(UserEntity, ClassId)); }