Exemple #1
0
        public async Task <IEnumerable <TimeMileageModel> > InsertTimeMileageListAsync(IEnumerable <TimeMileageModel> timeMileages)
        {
            var user = await userRepository.GetUser();

            List <TimeMileageModel> timeMileageList = new List <TimeMileageModel>();

            foreach (var timeMileage in timeMileages)
            {
                var timeMileageVar = new TimeMileageModel
                {
                    SyncId             = timeMileage.SyncId,
                    StartTime          = timeMileage.StartTime,
                    EndTime            = timeMileage.EndTime,
                    Duration           = timeMileage.Duration,
                    Mileage            = timeMileage.Mileage,
                    CreatorUserId      = requestIdentityProvider.UserId,
                    LastModifierUserId = requestIdentityProvider.UserId,
                    DateCreated        = timeMileage.DateCreated,
                    AddedDate          = DateTime.Now,
                    TenantId           = user.TenantId,
                    UserId             = requestIdentityProvider.UserId
                };
                timeMileageList.Add(timeMileageVar);
                var newActivityList = timeMileageRepository.InsertTimeMileageList(mapper.Map <IEnumerable <TimeMileage> >(timeMileageList));
                await timeMileageRepository.SaveChangesAsync();
            }
            return(timeMileageList);
        }
Exemple #2
0
        public async Task <TimeMileageModel> InsertTimeMileageAsync(TimeMileageModel timeMileage)
        {
            var user = await userRepository.GetUser();

            timeMileage.AddedDate          = DateTime.Now;
            timeMileage.TenantId           = user.TenantId;
            timeMileage.CreatorUserId      = requestIdentityProvider.UserId;
            timeMileage.LastModifierUserId = requestIdentityProvider.UserId;
            var newTimeMileage = await timeMileageRepository.InsertAsync(mapper.Map <TimeMileage>(timeMileage));

            await timeMileageRepository.SaveChangesAsync();

            return(mapper.Map <TimeMileageModel>(newTimeMileage));
        }
Exemple #3
0
        public async Task <TimeMileageModel> UpdateTimeMileageAsync(TimeMileageModel timeMileage)
        {
            var user = await userRepository.GetUser();

            var timeMileageForUpdate = await timeMileageRepository.GetTimeMileage(timeMileage.DateCreated);

            timeMileageForUpdate.ModifiedDate       = DateTime.Now;
            timeMileageForUpdate.EndTime            = timeMileage.EndTime;
            timeMileageForUpdate.Duration           = timeMileage.Duration;
            timeMileageForUpdate.TenantId           = user.TenantId;
            timeMileageForUpdate.LastModifierUserId = requestIdentityProvider.UserId;
            await timeMileageRepository.SaveChangesAsync();

            return(mapper.Map <TimeMileageModel>(timeMileageForUpdate));
        }