Ejemplo n.º 1
0
        /// <summary>
        /// the method deletes a online drive storage service from the database by id
        /// </summary>
        /// <returns>list of services</returns>
        public bool DeleteOnlineDriveStorageService(int id)
        {
            OnlineDriveStorageService Service = _Ctx.OnlineDriveStorageService.Find(id);

            _Ctx.OnlineDriveStorageService.Remove(Service);
            return(1 == _Ctx.SaveChanges());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// the method puts a new online drive storage services from the database
        /// </summary>
        /// <returns>list of services</returns>
        public ResponseWrapper <OnlineDriveStorageService> PutOnlineDriveStorageService(OnlineDriveStorageService Service)
        {
            validateNMRelations(Service);
            OnlineDriveStorageService OldService = _Ctx.OnlineDriveStorageService.Find(Service.Id);

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

            overwriteService(OldService, Service);

            _Ctx.SaveChanges();

            return(new ResponseWrapper <OnlineDriveStorageService>
            {
                state = HttpStatusCode.OK,
                content = OldService
            });
        }
Ejemplo n.º 3
0
 /// <summary>
 /// the method posts a new online drive storage service to the database
 /// </summary>
 /// <returns>the posted online drive storage service</returns>
 public OnlineDriveStorageService PostOnlineDriveStorageService(OnlineDriveStorageService OnlineDriveStorageService)
 {
     OnlineDriveStorageService              = (OnlineDriveStorageService)validateNMRelations(OnlineDriveStorageService);
     OnlineDriveStorageService.Creation     = DateTime.Now;
     OnlineDriveStorageService.LastModified = DateTime.Now;
     _Ctx.OnlineDriveStorageService.Add(OnlineDriveStorageService);
     _Ctx.SaveChanges();
     return(OnlineDriveStorageService);
 }
        public IHttpActionResult PostOnlineDriveStorageServices([FromBody] OnlineDriveStorageService Service)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            if (!_SecRepo.IsAllowed(User.Identity.Name, "create-services"))
            {
                return(StatusCode(HttpStatusCode.Forbidden));
            }
            var _Resp = _Repo.PostOnlineDriveStorageService(Service);

            if (_Resp == null)
            {
                return(NotFound());
            }
            return(Ok(_Resp));
        }
        public IHttpActionResult PutOnlineDriveStorageServices([FromBody] OnlineDriveStorageService Service)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            if (!_SecRepo.IsAllowed(User.Identity.Name, "edit-services"))
            {
                return(StatusCode(HttpStatusCode.Forbidden));
            }
            var _Resp = _Repo.PutOnlineDriveStorageService(Service);

            if (_Resp.error == null)
            {
                return(Content(_Resp.state, _Resp.content));
            }
            else
            {
                return(Content(_Resp.state, _Resp.error));
            }
        }