private void CreateOrUpdateDocument() { try { this.lblError.Text = String.Empty; if (String.IsNullOrEmpty(this.txtBoxTitle.Text)) { return; } if (documentDto == null) { if (!_fileDetailsKvp.HasValue) { this.lblError.Text = "Morate priložiti fajl."; return; } documentDto = new DocumentDTO(); } documentDto.Title = txtBoxTitle.Text; documentDto.Keywords = new List <KeywordDTO>(); foreach (object obj in boxKeywords.Items) { string value = obj as string; if (!String.IsNullOrEmpty(value)) { documentDto.Keywords.Add(new KeywordDTO() { Name = value }); } } documentDto.DocumentShares = _sharedWith; if (documentDto.Id > 0) { _formsService.DocumentsService.UpdateDocumentData(documentDto, _formsService.GetLoggedUser().Id); } else { documentDto.Extension = _fileDetailsKvp.Value.Value; documentDto = _formsService.DocumentsService.SaveNewDocument(documentDto, _formsService.GetLoggedUser().Id); string newPath = _formsService.DocumentsService.AddNewDocumentVersion(documentDto); _filesService.SaveFileToServer(_fileDetailsKvp.Value.Key, newPath); } _formsService.ActivateForm(FormTypeCodes.MainForm); documentDto = null; } catch (Exception ex) { BusinessServiceBase.logger.Error(ex.Message); this.lblError.Text = "Došlo je do sistemske greške. Kontaktirajte administratora."; documentDto = null; } }