public async Task <IActionResult> IAMToken([FromBody] JObject request) { var watch = System.Diagnostics.Stopwatch.StartNew(); string methodName = "IAMToken"; ResponseDTO response = new ResponseDTO(); try { Log.Write(appSettings, LogEnum.DEBUG.ToString(), label, className, methodName, $"REQUEST: {JsonConvert.SerializeObject(request)}"); response.Result = await ObjectStorageService.IamToken(appSettings, request["apikey"].ToString()); response.Success = true; watch.Stop(); Log.Write(appSettings, LogEnum.INFO.ToString(), label, className, methodName, $"RESULT: {JsonConvert.SerializeObject(response)} Execution Time: {watch.ElapsedMilliseconds} ms"); return(Ok(response)); } catch (Exception e) { response.Success = false; response.Msg = e.Message; watch.Stop(); Log.Write(appSettings, LogEnum.ERROR.ToString(), label, className, methodName, $"ERROR: {JsonConvert.SerializeObject(request)}"); Log.Write(appSettings, LogEnum.ERROR.ToString(), label, className, methodName, $"ERROR: {e.Source + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace}"); return(BadRequest(response)); } }
/// <summary> /// the method deletes a object storage service from the database by id /// </summary> /// <returns>1 = success </returns> public bool DeleteObjectStorageService(int id) { ObjectStorageService Service = _Ctx.ObjectStorageService.Find(id); _Ctx.ObjectStorageService.Remove(Service); return(1 == _Ctx.SaveChanges()); }
/// <summary> /// the method puts a new object storage service from the database /// </summary> /// <returns>the puted object storage service</returns> public ResponseWrapper <ObjectStorageService> PutObjectStorageService(ObjectStorageService Service) { validateNMRelations(Service); ObjectStorageService OldService = _Ctx.ObjectStorageService.Find(Service.Id); if (OldService == null) { return new ResponseWrapper <ObjectStorageService> { state = HttpStatusCode.NotFound, error = "Fehler beim Speichern: Service konnte nicht gefunden werden" } } ; overwriteService(OldService, Service); _Ctx.SaveChanges(); return(new ResponseWrapper <ObjectStorageService> { state = HttpStatusCode.OK, content = OldService }); }
/// <summary> /// the method posts a new object storage service to the database /// </summary> /// <returns>the posted object storage service</returns> public ObjectStorageService PostObjectStorageService(ObjectStorageService ObjectStorageService) { ObjectStorageService.Creation = DateTime.Now; ObjectStorageService.LastModified = DateTime.Now; _Ctx.ObjectStorageService.Add(ObjectStorageService); _Ctx.SaveChanges(); return(ObjectStorageService); }
public IHttpActionResult PutObjectStorageServices([FromBody] ObjectStorageService Service) { if (!_SecRepo.IsAllowed(User.Identity.Name, "edit-services")) { return(StatusCode(HttpStatusCode.Forbidden)); } return(Ok(_Repo.PutObjectStorageService(Service))); }
public AttachmentController( ObjectStorageService oss, DatabaseService db, EmailSendingService send) { this.oss = oss; this.db = db; this.send = send; }
public async Task <IActionResult> ObjectStorageDownload([FromBody] JObject request) { var watch = System.Diagnostics.Stopwatch.StartNew(); string methodName = "ObjectStorageDownload"; ResponseDTO response = new ResponseDTO(); try { Log.Write(appSettings, LogEnum.DEBUG.ToString(), label, className, methodName, $"REQUEST: {JsonConvert.SerializeObject(request)}"); return(File(await ObjectStorageService.Download(appSettings, CommonService.JObjectToDictionary(request)), "application/octet-stream")); } catch (Exception e) { response.Success = false; response.Msg = e.Message; watch.Stop(); Log.Write(appSettings, LogEnum.ERROR.ToString(), label, className, methodName, $"ERROR: {JsonConvert.SerializeObject(request)}"); Log.Write(appSettings, LogEnum.ERROR.ToString(), label, className, methodName, $"ERROR: {e.Source + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace}"); return(BadRequest(response)); } }