Exemple #1
0
        public ServiceResponse <WatchHistoryDto> Update(int id, int userId, WatchHistoryDto model)
        {
            var response = new ServiceResponse <WatchHistoryDto>();

            try
            {
                model.UserId = userId;
                if (model.Id == id)
                {
                    var item = new WatchHistory();
                    item.UserId   = userId;
                    item.Id       = model.Id;
                    item.CourseId = model.CourseId;

                    _repository.Update(item);
                    response.IsSuccessful = true;
                }
            }
            catch (Exception)
            {
                response.ExceptionMessage = ErrorCodes.BilinmeyenHata.Text;
                response.IsSuccessful     = false;
            }

            return(response);
        }
Exemple #2
0
        public ServiceResponse <WatchHistoryDto> WatchStatus(WatchHistoryDto watchHistoryDto)
        {
            if (watchHistoryDto.UserId != null && watchHistoryDto.CourseId != null)
            {
                var item = _repository.Table.FirstOrDefault(x => x.CourseId == watchHistoryDto.CourseId && x.UserId == watchHistoryDto.UserId && EntityFunctions.TruncateTime(x.DateAdded) == EntityFunctions.TruncateTime(DateTime.Now));

                if (item != null)
                {
                    _repository.Delete(item);
                }
                else
                {
                    _repository.Insert(new WatchHistory {
                        CourseId = watchHistoryDto.CourseId, UserId = watchHistoryDto.UserId, DateAdded = DateTime.Now
                    });
                }
            }

            return(null);
        }
Exemple #3
0
        public ServiceResponse <WatchHistoryDto> Insert(int userId, WatchHistoryDto model)
        {
            var response = new ServiceResponse <WatchHistoryDto>();

            try
            {
                var item = new WatchHistory();
                item.UserId    = userId;
                item.CourseId  = model.CourseId;
                item.DateAdded = DateTime.Now;


                _repository.Insert(item);
                response.IsSuccessful = true;
            }
            catch (Exception)
            {
                response.ExceptionMessage = ErrorCodes.BilinmeyenHata.Text;
                response.IsSuccessful     = false;
            }

            return(response);
        }
Exemple #4
0
 public async Task <ServiceResponse <WatchHistoryDto> > WatchStatus(WatchHistoryDto model)
 {
     return(_repository.WatchStatus(model));
 }
Exemple #5
0
 public async Task <ServiceResponse <WatchHistoryDto> > Put(int id, int userId, WatchHistoryDto model)
 {
     return(_repository.Update(id, userId, model));
 }
Exemple #6
0
 public async Task <ServiceResponse <WatchHistoryDto> > Post(int userId, WatchHistoryDto model)
 {
     return(_repository.Insert(userId, model));
 }