Beispiel #1
0
        /// <summary>
        /// the method deletes a direct attached storage service from the database by id
        /// </summary>
        /// <returns>1 = success </returns>
        public bool DeleteDirectAttachedStorageService(int id)
        {
            DirectAttachedStorageService Service = _Ctx.DirectAttachedStorageService.Find(id);

            _Ctx.DirectAttachedStorageService.Remove(Service);
            return(1 == _Ctx.SaveChanges());
        }
Beispiel #2
0
        /// <summary>
        /// the method puts a new direct attached storage service from the database
        /// </summary>
        /// <returns>the puted direct attached storage service</returns>
        public ResponseWrapper <DirectAttachedStorageService> PutDirectAttachedStorageService(DirectAttachedStorageService Service)
        {
            validateNMRelations(Service);
            DirectAttachedStorageService OldService = _Ctx.DirectAttachedStorageService.Find(Service.Id);

            if (OldService == null)
            {
                return new ResponseWrapper <DirectAttachedStorageService>
                       {
                           state = HttpStatusCode.NotFound,
                           error = "Fehler beim Speichern: Service konnte nicht gefunden werden"
                       }
            }
            ;

            overwriteService(OldService, Service);

            OldService.StorageTypeId = Service.StorageTypeId;

            _Ctx.SaveChanges();

            return(new ResponseWrapper <DirectAttachedStorageService>
            {
                state = HttpStatusCode.OK,
                content = OldService
            });
        }
 public IHttpActionResult PutDirectAttachedStorageServices([FromBody] DirectAttachedStorageService Service)
 {
     if (!_SecRepo.IsAllowed(User.Identity.Name, "edit-services"))
     {
         return(StatusCode(HttpStatusCode.Forbidden));
     }
     return(Ok(_Repo.PutDirectAttachedStorageService(Service)));
 }
Beispiel #4
0
 /// <summary>
 /// the method posts a new direct attached storage service to the database
 /// </summary>
 /// <returns>the posted direct attached storage service</returns>
 public DirectAttachedStorageService PostDirectAttachedStorageService(DirectAttachedStorageService DirectAttachedStorageService)
 {
     DirectAttachedStorageService              = (DirectAttachedStorageService)validateNMRelations(DirectAttachedStorageService);
     DirectAttachedStorageService.Creation     = DateTime.Now;
     DirectAttachedStorageService.LastModified = DateTime.Now;
     _Ctx.DirectAttachedStorageService.Add(DirectAttachedStorageService);
     _Ctx.SaveChanges();
     return(DirectAttachedStorageService);
 }
Beispiel #5
0
        /// <summary>
        /// the method returns a direct attached storage service from the database by id
        /// </summary>
        /// <returns> a specific direct attached storage service</returns>
        public ResponseWrapper <DirectAttachedStorageService> GetDirectAttachedStorageService(int id)
        {
            DirectAttachedStorageService directAttachedStorageService = _Ctx.DirectAttachedStorageService.Find(id);

            if (directAttachedStorageService == null)
            {
                return new ResponseWrapper <DirectAttachedStorageService>
                       {
                           error = $"Fehler beim Abrufen: Direct Attached Storage Service mit der ID {directAttachedStorageService.Id} konnte nicht gefunden werden",
                           state = HttpStatusCode.NotFound
                       }
            }
            ;
            return(new ResponseWrapper <DirectAttachedStorageService>
            {
                content = directAttachedStorageService,
                state = HttpStatusCode.OK
            });
        }