using System.Collections.Generic;
using Test.BusinessLayer.Exceptions;
using Test.Localize.Resources;
using Test.Global.Attributes;
public class ClustersController : BaseApiController
public ITestService ServicesBLL { get; set; }
[Rights(UserRightType.Catalogs, UserRightSubType.Read)]
public IEnumerable<Cluster> Get()
return ServicesBLL.Clusters.GetAll();
catch (BusinessException ex)
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
Log.Error(Resource.Ошибка_получения_данных, ex);
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Resource.Ошибка_получения_данных));
[Rights(UserRightType.Catalogs, UserRightSubType.Create)]
public bool Create(Cluster cluster)
return ServicesBLL.Clusters.Add(cluster) != default(Guid);
catch (BusinessException ex)
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
Log.Error(ex, @"api\Clusters\Create");
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Resource.Ошибка_добавления_данных));
public bool Update(Cluster cluster)
if (!CurrentUser.HasRight(UserRightType.Catalogs, UserRightSubType.Change))
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.Forbidden, Resource.Нет_прав_на_данную_операцию));
return ServicesBLL.Clusters.Update(cluster);
catch (BusinessException ex)
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
Log.Error(ex, @"api\Clusters\Update");
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Resource.Ошибка_изменения_данных));
[Rights(UserRightType.Catalogs, UserRightSubType.Delete)]
public bool Delete(Guid id)
return ServicesBLL.Clusters.Delete(id);
catch (BusinessException ex)
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
Log.Error(ex, @"api\Clusters\Delete");
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Resource.Ошибка_удаления_данных));