Example #1
0
        public IHttpActionResult Get()
        {
            FrequencyService frequencyService = new FrequencyService();
            var data = frequencyService.GetListFrequency();

            return(Ok(data));
        }
        Task <bool> IRequestHandler <UpdateFrequencyRequest, bool> .Handle(UpdateFrequencyRequest request, CancellationToken cancellationToken)
        {
            var existingFrequency = FrequencyService.Get(request.Frequency.Id);

            if (existingFrequency == null)
            {
                throw new ApplicationException($"UpdateFrequencyHandler: Frequency with Id {request.Frequency.Id} does not exist.");
            }

            //AutoMapper to Map the fields
            Mapper.Map(request.Frequency, existingFrequency);

            using (var ts = new TransactionScope())
            {
                var updatedFrequency = FrequencyService.Update(existingFrequency);

                ts.Complete();
            }
            return(Task.FromResult(true));
        }
Example #3
0
 public FrequencyController(ExpenseItContext context, IMapper mapper)
 {
     _service = new FrequencyService(context, mapper);
 }