Ejemplo n.º 1
0
        public async Task <IEnumerable <FormValueModel> > InsertFormValueListAsync(IEnumerable <FormValueModel> formValues)
        {
            var user = await userRepository.GetUser();

            List <FormValueModel> formValueList = new List <FormValueModel>();

            foreach (var formValue in formValues)
            {
                var formValueVar = new FormValueModel
                {
                    SyncId             = formValue.SyncId,
                    PlaceId            = formValue.PlaceId,
                    ScheduleId         = formValue.ScheduleId,
                    FormId             = formValue.FormId,
                    FormFieldValues    = formValue.FormFieldValues,
                    AddedDate          = DateTime.Now,
                    TenantId           = user.TenantId,
                    RepoId             = formValue.RepoId,
                    CreatorUserId      = requestIdentityProvider.UserId,
                    LastModifierUserId = requestIdentityProvider.UserId
                };
                formValueList.Add(formValueVar);
            }
            var newFormValueList = formValueRepository.InsertFormValueList(mapper.Map <IEnumerable <FormValue> >(formValueList));
            await formValueRepository.SaveChangesAsync();

            return(formValueList);
        }
Ejemplo n.º 2
0
        public async Task <FormValueModel> InsertFormValueAsync(FormValueModel formValue)
        {
            var user = await userRepository.GetUser();

            formValue.AddedDate = DateTime.Now;

            formValue.TenantId           = user.TenantId;
            formValue.CreatorUserId      = requestIdentityProvider.UserId;
            formValue.LastModifierUserId = requestIdentityProvider.UserId;

            var newFormValue = await formValueRepository.InsertAsync(mapper.Map <FormValue>(formValue));

            await formValueRepository.SaveChangesAsync();

            return(mapper.Map <FormValueModel>(newFormValue));
        }
Ejemplo n.º 3
0
        public async Task <FormValueModel> UpdateFormValueAsync(FormValueModel formValue)
        {
            var formValueForUpdate = await formValueRepository.GetAsync(formValue.Id);

            var user = await userRepository.GetUser();

            formValueForUpdate.ModifiedDate       = DateTime.Now;
            formValueForUpdate.FormFieldValues    = formValue.FormFieldValues;
            formValueForUpdate.FormId             = formValue.FormId;
            formValueForUpdate.PlaceId            = formValue.PlaceId;
            formValueForUpdate.ScheduleId         = formValue.ScheduleId;
            formValueForUpdate.TenantId           = user.TenantId;
            formValueForUpdate.RepoId             = formValue.RepoId;
            formValueForUpdate.LastModifierUserId = requestIdentityProvider.UserId;
            await formValueRepository.SaveChangesAsync();

            return(mapper.Map <FormValueModel>(formValueForUpdate));
        }
Ejemplo n.º 4
0
        public async Task <IEnumerable <ActivityModel> > GetActivitiesAsync(DateTime dateFrom, DateTime dateTo)
        {
            IList <ActivityModel> lstActivities = new List <ActivityModel>();
            var allActivities = mapper.Map <IEnumerable <ActivityModel> >(await activityRepository.GetActivities(dateFrom, dateTo));
            //var allActivities = await activityRepository.GetActivities(dateFrom, dateTo);

            FormValueModel          formValue          = null;
            NoteModel               note               = null;
            OrderModel              orders             = null;
            PhotoModel              photo              = null;
            ProductRetailAuditModel productRetailAudit = null;


            foreach (var activity in allActivities)
            {
                formValue          = mapper.Map <FormValueModel>(await formValueRepository.GetFormValue(activity.ActivityTypeId));
                note               = mapper.Map <NoteModel>(await noteRepository.GetNote(activity.ActivityTypeId));
                orders             = mapper.Map <OrderModel>(await orderRepository.GetOrder(activity.ActivityTypeId));
                photo              = mapper.Map <PhotoModel>(await photoRepository.GetPhoto(activity.ActivityTypeId));
                productRetailAudit = mapper.Map <ProductRetailAuditModel>(await productRetailAuditRepository.GetProductRetailAudit(activity.ActivityTypeId));


                var activityVar = new ActivityModel
                {
                    Id                 = activity.Id,
                    PlaceId            = activity.PlaceId,
                    ActivityLog        = activity.ActivityLog,
                    ActivityTypeId     = activity.ActivityTypeId,
                    DateCreated        = activity.DateCreated,
                    FormValue          = formValue,
                    Note               = note,
                    Order              = orders,
                    Photo              = photo,
                    ProductRetailAudit = productRetailAudit,
                    UserId             = requestIdentityProvider.UserId,
                    User               = activity.User,
                    Place              = activity.Place,
                    Submitted          = 4
                };
                lstActivities.Add(activityVar);
            }
            return(lstActivities);
        }