-
Notifications
You must be signed in to change notification settings - Fork 11
/
BrandManager.cs
60 lines (52 loc) · 1.6 KB
/
BrandManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using Business.Abstract;
using Business.BusinessAspect.Autofac;
using Business.Constants;
using Business.ValidationRules.FluentValidation;
using Core.Aspects.Autofac.Validation;
using Core.CrossCuttingConcerns.Validation;
using Core.Utilities.Results;
using DataAccess.Abstract;
using Entities.Concrete;
using FluentValidation;
using System;
using System.Collections.Generic;
using System.Text;
namespace Business.Concrete
{
public class BrandManager : IBrandService
{
IBrandDal _brandDal;
public BrandManager(IBrandDal brandDal)
{
_brandDal = brandDal;
}
[SecuredOperation("admin")]
[ValidationAspect(typeof(BrandValidator))]
public IResult Add(Brand brand)
{
_brandDal.Add(brand);
return new SuccessResult(Messages.AddedBrand);
}
[SecuredOperation("admin")]
public IResult Delete(Brand brand)
{
_brandDal.Delete(brand);
return new SuccessResult(Messages.DeletedBrand);
}
public IDataResult<List<Brand>> GetAll()
{
return new SuccessDataResult<List<Brand>>(_brandDal.GetAll());
}
public IDataResult<Brand> GetById(int id)
{
return new SuccessDataResult<Brand>(_brandDal.Get(c => c.Id == id));
}
[SecuredOperation("admin")]
[ValidationAspect(typeof(BrandValidator))]
public IResult Update(Brand brand)
{
_brandDal.Update(brand);
return new SuccessResult(Messages.UpdatedBrand);
}
}
}