コード例 #1
0
        public string UpdateThemesFromEdit(UpdateDocumentDTO updateDTO)
        {
            switch (updateDTO.id.ToString()[0])
            {
            case '1':
                var art = GetArtPiece(updateDTO.id);
                Data.Update(art);
                changeArtThemes(art, updateDTO.update);
                Data.SaveChanges();
                break;

            case '2':
                var poem = GetPoem(updateDTO.id);
                changePoemThemes(poem, updateDTO.update);
                Data.SaveChanges();
                break;

            case '3':
                var writing = GetWritingAssignment(updateDTO.id);
                changeWritingThemes(writing, updateDTO.update);
                Data.SaveChanges();
                break;

            default:
                return("Bad");
            }
            return("Ok");
        }
コード例 #2
0
        public string UpdateName(UpdateDocumentDTO updateDTO)
        {
            switch (updateDTO.id.ToString()[0])
            {
            case '1':
                var art = GetArtPiece(updateDTO.id);
                Data.Update(art);
                art.Title = updateDTO.update;
                Data.SaveChanges();
                return(art.Title);

            case '2':
                var poem = GetPoem(updateDTO.id);
                poem.Title = updateDTO.update;
                Data.SaveChanges();
                return(poem.Title);

            case '3':
                var writing = GetWritingAssignment(updateDTO.id);
                writing.Title = updateDTO.update;
                Data.SaveChanges();
                return(writing.Title);

            default:
                return("Bad");
            }
            return("Ok");
        }
コード例 #3
0
 public IActionResult UpdateThemesFromEdit([FromBody] UpdateDocumentDTO updateDTO)
 {
     return(Ok(DocumentManager.UpdateThemesFromEdit(updateDTO)));
 }
コード例 #4
0
 public IActionResult UpdateName([FromBody] UpdateDocumentDTO updateDTO)
 {
     return(Ok(DocumentManager.UpdateName(updateDTO)));
 }
コード例 #5
0
        public async Task <IActionResult> UpdateCollection(DocumentViewModel document, List <IFormFile> file, List <IFormFile> datasetfile)
        {
            var response = new Result();

            try
            {
                string userDept    = "";
                var    currentUser = HttpContext.Session.GetString(SessionHelper.USER_NAME);
                var    userId      = HttpContext.Session.GetString(SessionHelper.USER_ID);
                var    userRole    = HttpContext.Session.GetString(SessionHelper.ROLES);

                if (userRole == nameof(Role.DPO) || userRole == nameof(Role.ADMINISTRATOR))
                {
                    userDept = document.DepartmentId;
                }

                else if (userRole == nameof(Role.DEPTHEAD) || userRole == nameof(Role.USER))
                {
                    userDept = HttpContext.Session.GetString(SessionHelper.USER_DEPT);
                }
                document.DocumentField        = JsonConvert.DeserializeObject <List <DocumentFieldViewModel> >(document.JsonDocumentField);
                document.DocumentDatasetField = JsonConvert.DeserializeObject <List <DocumentDatasetFieldViewModel> >(document.JsonDatasetField);

                //adding new data set
                if (string.IsNullOrEmpty(document.Id.ToString()) || document.Id == 0)
                {
                    var doc = _mapper.Map <AddDocumentDTO>(document);
                    var dto = new AddDocumentDTO();
                    dto               = doc;
                    dto.Status        = Status.Collection;
                    dto.DocumentField = doc.DocumentField;
                    dto.DatasetId     = document.DatasetId;

                    response = await _adminService.AddDocument(dto, file, datasetfile, userRole, userId, userDept);
                }
                //updating data set
                else
                {
                    var doc = _mapper.Map <UpdateDocumentDTO>(document);
                    var dto = new UpdateDocumentDTO();
                    dto = doc;
                    dto.DocumentField = doc.DocumentField;
                    dto.DatasetId     = document.DatasetId;

                    //todo: UpdateDocument() and EditDocument() need merging.
                    if (userRole == nameof(Role.DPO) || userRole == nameof(Role.ADMINISTRATOR))
                    {
                        response = await _adminService.EditDocument(dto, Convert.ToInt32(document.SubModuleId), userRole, userId, userDept);
                    }

                    else if (userRole == nameof(Role.DEPTHEAD) || userRole == nameof(Role.USER))
                    {
                        response = await _adminService.EditDocument(dto, Convert.ToInt32(document.SubModuleId), userRole, userId, userDept);
                    }
                }
            }
            catch (Exception e)
            {
                _logger.LogError("Error Exception on Adding a Collection: " + e.Message.ToString());
            }
            return(Json(response));
        }