Ejemplo n.º 1
0
        /// <summary>
        /// the method deletes a key value store service from the database by id
        /// </summary>
        /// <returns>list of services</returns>
        public bool DeleteKeyValueStoreService(int id)
        {
            KeyValueStorageService Service = _Ctx.KeyValueStoreService.Find(id);

            _Ctx.KeyValueStoreService.Remove(Service);
            return(1 == _Ctx.SaveChanges());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// the method puts a new key value store services from the database
        /// </summary>
        /// <returns>list of services</returns>
        public ResponseWrapper <KeyValueStorageService> PutKeyValueStoreService(KeyValueStorageService Service)
        {
            validateNMRelations(Service);
            KeyValueStorageService OldService = _Ctx.KeyValueStoreService.Find(Service.Id);

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

            overwriteService(OldService, Service);

            _Ctx.SaveChanges();

            return(new ResponseWrapper <KeyValueStorageService>
            {
                state = HttpStatusCode.OK,
                content = OldService
            });
        }
Ejemplo n.º 3
0
 /// <summary>
 /// the method posts a new key value store service to the database
 /// </summary>
 /// <returns>the posted key value store service</returns>
 public KeyValueStorageService PostKeyValueStoreService(KeyValueStorageService Service)
 {
     Service.Creation     = DateTime.Now;
     Service.LastModified = DateTime.Now;
     _Ctx.KeyValueStoreService.Add(Service);
     _Ctx.SaveChanges();
     return(Service);
 }
 public IHttpActionResult PutKeyValueStoreServices([FromBody] KeyValueStorageService Service)
 {
     if (!_SecRepo.IsAllowed(User.Identity.Name, "edit-services"))
     {
         return(StatusCode(HttpStatusCode.Forbidden));
     }
     return(Ok(_Repo.PutKeyValueStoreService(Service)));
 }