コード例 #1
0
        public IHttpActionResult PostSubSectionTab(SubSectionTab subSectionTab)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!IsUserSiteAdmin() && !IsUserLeadClinician())
            {
                return(Unauthorized());
            }

            subSectionTab._id = Guid.NewGuid();

            _db.SubSectionTabs.Add(subSectionTab);

            _db.Logs.Add(
                _logHelper.CreateSubSectionTabApiControllerLog(
                    LogHelper.LogType.Create,
                    "SubSectionTabApiController.PostSubSectionTab",
                    "api/subsectiontab/post",
                    subSectionTab,
                    User.GetUsernameWithoutDomain()
                    )
                );

            _db.SaveChanges();

            return(Ok(subSectionTab));
        }
 private void CheckSubSectionTab(SubSectionTab subSectionTab, SubSectionTab checkSubSectionTab)
 {
     Assert.AreEqual(checkSubSectionTab.Id, subSectionTab.Id);
     Assert.AreEqual(checkSubSectionTab._id, subSectionTab._id);
     Assert.AreEqual(checkSubSectionTab.DepartmentId, subSectionTab.DepartmentId);
     Assert.AreEqual(checkSubSectionTab.Name, subSectionTab.Name);
     Assert.AreEqual(checkSubSectionTab.Icon, subSectionTab.Icon);
 }
コード例 #3
0
        public IHttpActionResult PutSubSectionTab(int id, SubSectionTab subSectionTab)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!IsUserSiteAdmin() && !IsUserLeadClinician())
            {
                return(Unauthorized());
            }

            if (id != subSectionTab.Id)
            {
                return(BadRequest());
            }

            if (subSectionTab._id == Guid.Empty)
            {
                subSectionTab._id = Guid.NewGuid();
            }

            _db.Logs.Add(
                _logHelper.CreateSubSectionTabApiControllerLog(
                    LogHelper.LogType.Update,
                    "SubSectionTabApiController.PutSubSectionTab",
                    $"api/subsectiontab/put/{id}",
                    subSectionTab,
                    User.GetUsernameWithoutDomain()
                    )
                );

            _db.MarkSubSectionTabAsModified(subSectionTab);

            try
            {
                _db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SubSectionTabExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 private void AddDemoToInMemoryContext()
 {
     _inMemoryArticle         = GetDemoArticle();
     _inMemoryArticleRevision = GetDemoArticleRevision();
     _inMemoryDepartment      = GetDemoDepartment();
     _inMemorySubSectionTab   = GetDemoSubSectionTab();
     _inMemoryTerm            = GetDemoTerm();
     _context.Articles.Add(_inMemoryArticle);
     _context.ArticleRevisions.Add(_inMemoryArticleRevision);
     _context.Departments.Add(_inMemoryDepartment);
     _context.SubSectionTabs.Add(_inMemorySubSectionTab);
     _context.Terms.Add(_inMemoryTerm);
 }
 private void AddDemoToInMemoryContext()
 {
     _inMemorySubSectionTab                    = GetDemoSubSectionTab();
     _inMemoryGlobalSubSectionTab              = GetDemoSubSectionTab();
     _inMemoryGlobalSubSectionTab.Id           = GlobalSubSectionTabId;
     _inMemoryGlobalSubSectionTab.DepartmentId = null;
     _inMemoryDepartment = GetDemoDepartment();
     _inMemoryUser       = GetDemoUser();
     _context.SubSectionTabs.Add(_inMemorySubSectionTab);
     _context.SubSectionTabs.Add(_inMemoryGlobalSubSectionTab);
     _context.Departments.Add(_inMemoryDepartment);
     _context.Users.Add(_inMemoryUser);
 }
コード例 #6
0
        public Log CreateSubSectionTabApiControllerLog(LogType notificationType, string method, string requestUri, SubSectionTab subSectionTab, string samAccountName)
        {
            object action;
            var    details = new SubSectionTabDto()
            {
                Id           = subSectionTab.Id,
                _id          = subSectionTab._id,
                Name         = subSectionTab.Name,
                Archived     = subSectionTab.Archived,
                Icon         = subSectionTab.Icon,
                Live         = subSectionTab.Live,
                DepartmentId = subSectionTab.DepartmentId
            };

            switch (notificationType)
            {
            case LogType.Create:
                action = new
                {
                    Action  = $"Subsectiontab created {subSectionTab.Name}.",
                    Details = details
                };
                break;

            case LogType.Update:
                action = new
                {
                    Action  = $"Subsectiontab updated {subSectionTab.Name}.",
                    Details = details
                };
                break;

            case LogType.Archive:
                action = new
                {
                    Action  = $"Subsectiontab archive {subSectionTab.Name}.",
                    Details = details
                };
                break;

            default:
                action = null;
                break;
            }

            return(action != null?CreateLog(samAccountName, method, requestUri, action) : null);
        }
 public void MarkSubSectionTabAsModified(SubSectionTab subSectionTab)
 {
 }