public IHttpActionResult PostQuickFilterAssignment(string process, QuickFilterAssignment quickFilterAssignment)
        {
            if (quickFilterAssignment == null)
            {
                return BadRequest();
            }

            try
            {
                quickFilterAssignment.ProcessName = process;
                FilterRepository.AssignQuickFilter(quickFilterAssignment);

                return Ok();
            }
            catch (ProcessNotFoundException)
            {
                return NotFound();
            }
            catch (Exception ex)
            {
                Logger.Log(LogSeverity.Error, LoggerSource, ex);
                return InternalServerError();
            }
        }
Exemple #2
0
        /// <summary>
        /// Assigns a filter to a quick filter.
        /// </summary>
        /// <param name="quickFilterAssignment">
        /// The quick filter assignment.
        /// </param>
        public void AssignQuickFilter(QuickFilterAssignment quickFilterAssignment)
        {
            if (quickFilterAssignment == null)
                throw new ArgumentNullException("quickFilterAssignment");

            using (var transactionScope = TransactionUtils.CreateTransactionScope())
            {
                if (quickFilterAssignment.FilterId != null)
                {
                    SetQuickFilter(quickFilterAssignment.ProcessName, quickFilterAssignment.FilterId.Value, quickFilterAssignment.QuickFilter);
                }
                else
                {
                    if (quickFilterAssignment.QuickFilter != QuickFilters.None)
                    {
                        UnassignFilterFromQuickFilter(quickFilterAssignment.ProcessName, quickFilterAssignment.QuickFilter);
                    }
                }

                transactionScope.Complete();
            }
        }