/// <summary> /// the method puts a new block storage service from the database /// </summary> /// <returns>the puted block storage service</returns> public ResponseWrapper <BlockStorageService> PutBlockStorageService(BlockStorageService Service) { validateNMRelations(Service); BlockStorageService OldService = _Ctx.BlockStorageService.Find(Service.Id); if (OldService == null) { return new ResponseWrapper <BlockStorageService> { state = HttpStatusCode.NotFound, error = "no block storage service found with the given id for update" } } ; overwriteService(OldService, Service); OldService.StorageTypeId = Service.StorageTypeId; _Ctx.SaveChanges(); return(new ResponseWrapper <BlockStorageService> { state = HttpStatusCode.OK, content = OldService }); }
/// <summary> /// the method deletes a block storage service from the database by id /// </summary> /// <returns>1 = success </returns> public bool DeleteBlockStorageService(int id) { BlockStorageService Service = _Ctx.BlockStorageService.Find(id); _Ctx.BlockStorageService.Remove(Service); return(1 == _Ctx.SaveChanges()); }
public IHttpActionResult PostBlockStorageServices([FromBody] BlockStorageService Service) { if (!_SecRepo.IsAllowed(User.Identity.Name, "create-services")) { return(StatusCode(HttpStatusCode.Forbidden)); } return(Ok(_Repo.PostBlockStorageService(Service))); }
/// <summary> /// the method posts a new block storage service to the database /// </summary> /// <returns>the posted block storage service</returns> public BlockStorageService PostBlockStorageService(BlockStorageService BlockStorageService) { BlockStorageService = (BlockStorageService)validateNMRelations(BlockStorageService); BlockStorageService.Creation = DateTime.Now; BlockStorageService.LastModified = DateTime.Now; _Ctx.BlockStorageService.Add(BlockStorageService); _Ctx.SaveChanges(); return(BlockStorageService); }
public IHttpActionResult PutBlockStorageServices([FromBody] BlockStorageService Service) { if (!_SecRepo.IsAllowed(User.Identity.Name, "edit-services")) { return(StatusCode(HttpStatusCode.Forbidden)); } ResponseWrapper <BlockStorageService> response = _Repo.PutBlockStorageService(Service); if (response.error != null) { return(Content(response.state, response.error)); } return(Content(response.state, response.content)); }
/// <summary> /// the method returns a block storage service from the database by id /// </summary> /// <returns> a specific block storage service</returns> public ResponseWrapper <BlockStorageService> GetBlockStorageService(int id) { BlockStorageService blockStorageService = _Ctx.BlockStorageService.Find(id); if (blockStorageService == null) { return new ResponseWrapper <BlockStorageService> { state = HttpStatusCode.NotFound, error = "Fehler beim Abrufen: Blockstorageservice mit der ID " + id + " konnte nicht gefunden werden" } } ; return(new ResponseWrapper <BlockStorageService> { state = HttpStatusCode.OK, content = blockStorageService }); }