Ejemplo n.º 1
0
        public async Task <ExamProgram> Create(ExamProgram examProgram)
        {
            if (!await ExamProgramValidator.Create(examProgram))
            {
                return(examProgram);
            }

            using (UOW.Begin())
            {
                try
                {
                    examProgram.Id = Guid.NewGuid();

                    examProgram = await GetSemesterId(examProgram);

                    await UOW.ExamProgramRepository.Create(examProgram);

                    await UOW.Commit();

                    return(examProgram);
                }
                catch (Exception e)
                {
                    await UOW.Rollback();

                    examProgram.AddError(nameof(ExamProgramService), nameof(Create), CommonEnum.ErrorCode.SystemError);
                    return(examProgram);
                }
            }
        }
Ejemplo n.º 2
0
        public async Task <OrderContent> Create(OrderContent OrderContent)
        {
            if (!await OrderContentValidator.Create(OrderContent))
            {
                return(OrderContent);
            }

            try
            {
                await UOW.Begin();

                await UOW.OrderContentRepository.Create(OrderContent);

                await UOW.Commit();

                await Logging.CreateAuditLog(OrderContent, new { }, nameof(OrderContentService));

                return(await UOW.OrderContentRepository.Get(OrderContent.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await Logging.CreateSystemLog(ex.InnerException, nameof(OrderContentService));

                if (ex.InnerException == null)
                {
                    throw new MessageException(ex);
                }
                else
                {
                    throw new MessageException(ex.InnerException);
                }
            }
        }
Ejemplo n.º 3
0
        public async Task <Category> Create(Category Category)
        {
            if (!await CategoryValidator.Create(Category))
            {
                return(Category);
            }

            try
            {
                await UOW.Begin();

                await UOW.CategoryRepository.Create(Category);

                await UOW.Commit();

                await UOW.AuditLogRepository.Create(Category, "", nameof(CategoryService));

                return(await UOW.CategoryRepository.Get(Category.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await UOW.SystemLogRepository.Create(ex, nameof(CategoryService));

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 4
0
        public async Task <District> Create(District District)
        {
            if (!await DistrictValidator.Create(District))
            {
                return(District);
            }

            try
            {
                await UOW.Begin();

                await UOW.DistrictRepository.Create(District);

                await UOW.Commit();

                await UOW.AuditLogRepository.Create(District, "", nameof(DistrictService));

                return(await UOW.DistrictRepository.Get(District.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await UOW.SystemLogRepository.Create(ex, nameof(DistrictService));

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 5
0
        public async Task <FoodGrouping> Create(FoodGrouping FoodGrouping)
        {
            if (!await FoodGroupingValidator.Create(FoodGrouping))
            {
                return(FoodGrouping);
            }

            try
            {
                await UOW.Begin();

                await UOW.FoodGroupingRepository.Create(FoodGrouping);

                await UOW.Commit();

                await Logging.CreateAuditLog(FoodGrouping, new { }, nameof(FoodGroupingService));

                return(await UOW.FoodGroupingRepository.Get(FoodGrouping.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await Logging.CreateSystemLog(ex.InnerException, nameof(FoodGroupingService));

                if (ex.InnerException == null)
                {
                    throw new MessageException(ex);
                }
                else
                {
                    throw new MessageException(ex.InnerException);
                }
            }
        }
Ejemplo n.º 6
0
        public async Task <Variation> Create(Variation Variation)
        {
            if (!await VariationValidator.Create(Variation))
            {
                return(Variation);
            }

            try
            {
                await UOW.Begin();

                await UOW.VariationRepository.Create(Variation);

                await UOW.Commit();

                await UOW.AuditLogRepository.Create(Variation, "", nameof(VariationService));

                return(await UOW.VariationRepository.Get(Variation.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await UOW.SystemLogRepository.Create(ex, nameof(VariationService));

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 7
0
        public async Task <Administrator> Create(Administrator Administrator)
        {
            if (!await AdministratorValidator.Create(Administrator))
            {
                return(Administrator);
            }

            try
            {
                await UOW.Begin();

                await UOW.AdministratorRepository.Create(Administrator);

                await UOW.Commit();

                await UOW.AuditLogRepository.Create(Administrator, "", nameof(AdministratorService));

                return(await UOW.AdministratorRepository.Get(Administrator.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await UOW.SystemLogRepository.Create(ex, nameof(AdministratorService));

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 8
0
        public async Task <Item> Create(Item Item)
        {
            if (!await ItemValidator.Create(Item))
            {
                return(Item);
            }

            try
            {
                await UOW.Begin();

                await UOW.ItemRepository.Create(Item);

                await UOW.Commit();

                await UOW.AuditLogRepository.Create(Item, "", nameof(ItemService));

                return(await UOW.ItemRepository.Get(Item.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await UOW.SystemLogRepository.Create(ex, nameof(ItemService));

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 9
0
        public async Task <University> Create(University university)
        {
            university.Id = Guid.NewGuid();
            if (!await UniversityValidator.Create(university))
            {
                return(university);
            }

            try
            {
                await UOW.Begin();

                await UOW.UniversityRepository.Create(university);

                await UOW.Commit();

                return(await Get(university.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 10
0
        public async Task <Wallet> Create(Wallet wallet)
        {
            wallet.Id = Guid.NewGuid();

            if (wallet == null)
            {
                return(null);
            }
            if (!await WalletValidator.Create(wallet))
            {
                return(wallet);
            }

            using (UnitOfWork.Begin())
            {
                try
                {
                    await UnitOfWork.WalletRepository.Create(wallet);

                    await UnitOfWork.Commit();
                }
                catch (Exception ex)
                {
                    await UnitOfWork.Rollback();

                    wallet.AddError(nameof(WalletService), nameof(wallet.Id), CommonEnum.ErrorCode.SystemError);
                }
            }
            return(wallet);
        }
Ejemplo n.º 11
0
        public async Task <Form> ApproveAccept(Form form)
        {
            if (!await FormValidator.Approve(form))
            {
                return(form);
            }

            try
            {
                await UOW.Begin();

                //Chuyển trạng thái từ chờ duyệt sang đã duyệt
                form.Status = 2;
                await UOW.FormRepository.Approve(form);

                await UOW.StudentRepository.UpdateStatus(new Student { Id = form.StudentId, Status = form.Status });

                await UOW.Commit();

                return(await Get(form.StudentId));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 12
0
        public async Task <PaymentMethod> Create(PaymentMethod PaymentMethod)
        {
            if (!await PaymentMethodValidator.Create(PaymentMethod))
            {
                return(PaymentMethod);
            }

            try
            {
                await UOW.Begin();

                await UOW.PaymentMethodRepository.Create(PaymentMethod);

                await UOW.Commit();

                await UOW.AuditLogRepository.Create(PaymentMethod, "", nameof(PaymentMethodService));

                return(await UOW.PaymentMethodRepository.Get(PaymentMethod.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await UOW.SystemLogRepository.Create(ex, nameof(PaymentMethodService));

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 13
0
        public async Task <Reservation> Create(Reservation Reservation)
        {
            if (!await ReservationValidator.Create(Reservation))
            {
                return(Reservation);
            }

            try
            {
                await UOW.Begin();

                await UOW.ReservationRepository.Create(Reservation);

                await UOW.Commit();

                await Logging.CreateAuditLog(Reservation, new { }, nameof(ReservationService));

                return(await UOW.ReservationRepository.Get(Reservation.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await Logging.CreateSystemLog(ex.InnerException, nameof(ReservationService));

                if (ex.InnerException == null)
                {
                    throw new MessageException(ex);
                }
                else
                {
                    throw new MessageException(ex.InnerException);
                }
            }
        }
        public async Task <ProductStatus> Create(ProductStatus ProductStatus)
        {
            if (!await ProductStatusValidator.Create(ProductStatus))
            {
                return(ProductStatus);
            }

            try
            {
                await UOW.Begin();

                await UOW.ProductStatusRepository.Create(ProductStatus);

                await UOW.Commit();

                await UOW.AuditLogRepository.Create(ProductStatus, "", nameof(ProductStatusService));

                return(await UOW.ProductStatusRepository.Get(ProductStatus.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await UOW.SystemLogRepository.Create(ex, nameof(ProductStatusService));

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 15
0
        public async Task <ImageFile> Create(ImageFile ImageFile)
        {
            if (!await ImageFileValidator.Create(ImageFile))
            {
                return(ImageFile);
            }

            try
            {
                await UOW.Begin();

                await UOW.ImageFileRepository.Create(ImageFile);

                await UOW.Commit();

                await UOW.AuditLogRepository.Create(ImageFile, "", nameof(ImageFileService));

                return(await UOW.ImageFileRepository.Get(ImageFile.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await UOW.SystemLogRepository.Create(ex, nameof(ImageFileService));

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 16
0
        public async Task <Stock> Create(Stock Stock)
        {
            if (!await StockValidator.Create(Stock))
            {
                return(Stock);
            }

            try
            {
                await UOW.Begin();

                await UOW.StockRepository.Create(Stock);

                await UOW.Commit();

                await UOW.AuditLogRepository.Create(Stock, "", nameof(StockService));

                return(await UOW.StockRepository.Get(Stock.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await UOW.SystemLogRepository.Create(ex, nameof(StockService));

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 17
0
        public async Task <EVoucher> Create(EVoucher EVoucher)
        {
            if (!await EVoucherValidator.Create(EVoucher))
            {
                return(EVoucher);
            }

            try
            {
                await UOW.Begin();

                await UOW.EVoucherRepository.Create(EVoucher);

                await UOW.Commit();

                await UOW.AuditLogRepository.Create(EVoucher, "", nameof(EVoucherService));

                return(await UOW.EVoucherRepository.Get(EVoucher.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await UOW.SystemLogRepository.Create(ex, nameof(EVoucherService));

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 18
0
        public async Task <List <Store> > AddToCustomer(List <Store> Stores)
        {
            if (!await StoreValidator.AddToCustomer(Stores))
            {
                return(Stores);
            }

            try
            {
                await UOW.Begin();

                await UOW.StoreRepository.BulkMerge(Stores);

                await UOW.Commit();

                await Logging.CreateAuditLog(Stores, new { }, nameof(StoreService));

                return(Stores);
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    await Logging.CreateSystemLog(ex, nameof(StoreService));

                    throw new MessageException(ex);
                }
                else
                {
                    await Logging.CreateSystemLog(ex.InnerException, nameof(StoreService));

                    throw new MessageException(ex.InnerException);
                }
            }
        }
Ejemplo n.º 19
0
        public async Task <TicketType> Create(TicketType TicketType)
        {
            if (!await TicketTypeValidator.Create(TicketType))
            {
                return(TicketType);
            }

            try
            {
                await UOW.Begin();

                await UOW.TicketTypeRepository.Create(TicketType);

                await UOW.Commit();

                await Logging.CreateAuditLog(TicketType, new { }, nameof(TicketTypeService));

                return(await UOW.TicketTypeRepository.Get(TicketType.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await Logging.CreateSystemLog(ex.InnerException, nameof(TicketTypeService));

                if (ex.InnerException == null)
                {
                    throw new MessageException(ex);
                }
                else
                {
                    throw new MessageException(ex.InnerException);
                }
            }
        }
Ejemplo n.º 20
0
        public async Task <Term> Create(Term term)
        {
            if (!await TermValidator.Create(term))
            {
                return(term);
            }

            using (UOW.Begin())
            {
                try
                {
                    term.Id = Guid.NewGuid();

                    term = await GetSemesterId(term);

                    await UOW.TermRepository.Create(term);

                    await UOW.Commit();

                    return(term);
                }
                catch (Exception e)
                {
                    await UOW.Rollback();

                    term.AddError(nameof(TermService), nameof(Create), CommonEnum.ErrorCode.SystemError);
                    return(term);
                }
            }
        }
Ejemplo n.º 21
0
        public async Task <SubjectGroup> Create(SubjectGroup subjectGroup)
        {
            subjectGroup.Id = Guid.NewGuid();
            if (!await SubjectGroupValidator.Create(subjectGroup))
            {
                return(subjectGroup);
            }

            try
            {
                await UOW.Begin();

                await UOW.SubjectGroupRepository.Create(subjectGroup);

                await UOW.Commit();

                return(await Get(subjectGroup.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 22
0
        public async Task <OrderContent> Create(OrderContent OrderContent)
        {
            if (!await OrderContentValidator.Create(OrderContent))
            {
                return(OrderContent);
            }

            try
            {
                await UOW.Begin();

                await UOW.OrderContentRepository.Create(OrderContent);

                await UOW.Commit();

                await UOW.AuditLogRepository.Create(OrderContent, "", nameof(OrderContentService));

                return(await UOW.OrderContentRepository.Get(OrderContent.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await UOW.SystemLogRepository.Create(ex, nameof(OrderContentService));

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 23
0
        public async Task <WorkflowStep> Create(WorkflowStep WorkflowStep)
        {
            if (!await WorkflowStepValidator.Create(WorkflowStep))
            {
                return(WorkflowStep);
            }

            try
            {
                await UOW.Begin();

                await UOW.WorkflowStepRepository.Create(WorkflowStep);

                await UOW.Commit();

                await Logging.CreateAuditLog(WorkflowStep, new { }, nameof(WorkflowStepService));

                return(await UOW.WorkflowStepRepository.Get(WorkflowStep.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await Logging.CreateSystemLog(ex.InnerException, nameof(WorkflowStepService));

                if (ex.InnerException == null)
                {
                    throw new MessageException(ex);
                }
                else
                {
                    throw new MessageException(ex.InnerException);
                }
            }
        }
        public async Task <ShippingAddress> Create(ShippingAddress ShippingAddress)
        {
            if (!await ShippingAddressValidator.Create(ShippingAddress))
            {
                return(ShippingAddress);
            }

            try
            {
                await UOW.Begin();

                await UOW.ShippingAddressRepository.Create(ShippingAddress);

                await UOW.Commit();

                await UOW.AuditLogRepository.Create(ShippingAddress, "", nameof(ShippingAddressService));

                return(await UOW.ShippingAddressRepository.Get(ShippingAddress.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await UOW.SystemLogRepository.Create(ex, nameof(ShippingAddressService));

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 25
0
        public async Task <CustomerGrouping> Create(CustomerGrouping CustomerGrouping)
        {
            if (!await CustomerGroupingValidator.Create(CustomerGrouping))
            {
                return(CustomerGrouping);
            }

            try
            {
                await UOW.Begin();

                await UOW.CustomerGroupingRepository.Create(CustomerGrouping);

                await UOW.Commit();

                await UOW.AuditLogRepository.Create(CustomerGrouping, "", nameof(CustomerGroupingService));

                return(await UOW.CustomerGroupingRepository.Get(CustomerGrouping.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await UOW.SystemLogRepository.Create(ex, nameof(CustomerGroupingService));

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 26
0
        public async Task <ScheduleMaster> Create(ScheduleMaster ScheduleMaster)
        {
            if (!await ScheduleMasterValidator.Create(ScheduleMaster))
            {
                return(ScheduleMaster);
            }

            try
            {
                await UOW.Begin();

                await UOW.ScheduleMasterRepository.Create(ScheduleMaster);

                await UOW.Commit();

                await Logging.CreateAuditLog(ScheduleMaster, new { }, nameof(ScheduleMasterService));

                return(await UOW.ScheduleMasterRepository.Get(ScheduleMaster.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await Logging.CreateSystemLog(ex.InnerException, nameof(ScheduleMasterService));

                if (ex.InnerException == null)
                {
                    throw new MessageException(ex);
                }
                else
                {
                    throw new MessageException(ex.InnerException);
                }
            }
        }
Ejemplo n.º 27
0
        public async Task <Semester> Create(Semester semester)
        {
            if (!await SemesterValidator.Create(semester))
            {
                return(semester);
            }

            using (UOW.Begin())
            {
                try
                {
                    semester.Id = Guid.NewGuid();

                    await UOW.SemesterRepository.Create(semester);

                    await UOW.Commit();

                    return(await Get(semester.Id));
                }
                catch (Exception e)
                {
                    await UOW.Rollback();

                    semester.AddError(nameof(SemesterService), nameof(Create), CommonEnum.ErrorCode.SystemError);
                    return(semester);
                }
            }
        }
Ejemplo n.º 28
0
        public async Task <University_Majors> Create(University_Majors university_Majors)
        {
            if (!await university_MajorsValidator.Create(university_Majors))
            {
                return(university_Majors);
            }

            try
            {
                university_Majors.Id = Guid.NewGuid();
                await UOW.Begin();

                await UOW.University_MajorsRepository.Create(university_Majors);

                await UOW.Commit();

                return(await Get(university_Majors.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 29
0
        public async Task <Ward> Create(Ward Ward)
        {
            if (!await WardValidator.Create(Ward))
            {
                return(Ward);
            }

            try
            {
                await UOW.Begin();

                await UOW.WardRepository.Create(Ward);

                await UOW.Commit();

                await UOW.AuditLogRepository.Create(Ward, "", nameof(WardService));

                return(await UOW.WardRepository.Get(Ward.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await UOW.SystemLogRepository.Create(ex, nameof(WardService));

                throw new MessageException(ex);
            }
        }
Ejemplo n.º 30
0
        public async Task <Majors> Create(Majors majors)
        {
            majors.Id = Guid.NewGuid();
            if (!await MajorsValidator.Create(majors))
            {
                return(majors);
            }

            try
            {
                await UOW.Begin();

                await UOW.MajorsRepository.Create(majors);

                await UOW.Commit();

                return(await Get(majors.Id));
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                throw new MessageException(ex);
            }
        }