Beispiel #1
0
        public async Task <EVoucherContent> Update(EVoucherContent EVoucherContent)
        {
            if (!await EVoucherContentValidator.Update(EVoucherContent))
            {
                return(EVoucherContent);
            }
            try
            {
                var oldData = await UOW.EVoucherContentRepository.Get(EVoucherContent.Id);

                await UOW.Begin();

                await UOW.EVoucherContentRepository.Update(EVoucherContent);

                await UOW.Commit();

                var newData = await UOW.EVoucherContentRepository.Get(EVoucherContent.Id);

                await UOW.AuditLogRepository.Create(newData, oldData, nameof(EVoucherContentService));

                return(newData);
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

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

                throw new MessageException(ex);
            }
        }
Beispiel #2
0
        public async Task <EVoucherContent> Delete(EVoucherContent EVoucherContent)
        {
            if (!await EVoucherContentValidator.Delete(EVoucherContent))
            {
                return(EVoucherContent);
            }

            try
            {
                await UOW.Begin();

                await UOW.EVoucherContentRepository.Delete(EVoucherContent);

                await UOW.Commit();

                await UOW.AuditLogRepository.Create("", EVoucherContent, nameof(EVoucherContentService));

                return(EVoucherContent);
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

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

                throw new MessageException(ex);
            }
        }
 public async Task <bool> Delete(EVoucherContent EVoucherContent)
 {
     if (await ValidateId(EVoucherContent))
     {
     }
     return(EVoucherContent.IsValidated);
 }
Beispiel #4
0
 public EVoucherMaster_EVoucherContentDTO(EVoucherContent EVoucherContent)
 {
     this.Id           = EVoucherContent.Id;
     this.EVourcherId  = EVoucherContent.EVourcherId;
     this.UsedCode     = EVoucherContent.UsedCode;
     this.MerchantCode = EVoucherContent.MerchantCode;
     this.UsedDate     = EVoucherContent.UsedDate;
 }
        public async Task <bool> Delete(EVoucherContent EVoucherContent)
        {
            EVoucherContentDAO EVoucherContentDAO = await DataContext.EVoucherContent.Where(x => x.Id == EVoucherContent.Id).FirstOrDefaultAsync();

            DataContext.EVoucherContent.Remove(EVoucherContentDAO);
            await DataContext.SaveChangesAsync();

            return(true);
        }
Beispiel #6
0
 public EVoucherContentDetail_EVoucherContentDTO(EVoucherContent EVoucherContent)
 {
     this.Id           = EVoucherContent.Id;
     this.EVourcherId  = EVoucherContent.EVourcherId;
     this.UsedCode     = EVoucherContent.UsedCode;
     this.MerchantCode = EVoucherContent.MerchantCode;
     this.UsedDate     = EVoucherContent.UsedDate;
     this.EVourcher    = new EVoucherContentDetail_EVoucherDTO(EVoucherContent.EVourcher);
 }
Beispiel #7
0
        public async Task <EVoucherContent> Get(long Id)
        {
            EVoucherContent EVoucherContent = await UOW.EVoucherContentRepository.Get(Id);

            if (EVoucherContent == null)
            {
                return(null);
            }
            return(EVoucherContent);
        }
Beispiel #8
0
        public async Task <EVoucherContentMaster_EVoucherContentDTO> Get([FromBody] EVoucherContentMaster_EVoucherContentDTO EVoucherContentMaster_EVoucherContentDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new MessageException(ModelState);
            }

            EVoucherContent EVoucherContent = await EVoucherContentService.Get(EVoucherContentMaster_EVoucherContentDTO.Id);

            return(new EVoucherContentMaster_EVoucherContentDTO(EVoucherContent));
        }
        public async Task <bool> Update(EVoucherContent EVoucherContent)
        {
            EVoucherContentDAO EVoucherContentDAO = DataContext.EVoucherContent.Where(x => x.Id == EVoucherContent.Id).FirstOrDefault();

            EVoucherContentDAO.Id           = EVoucherContent.Id;
            EVoucherContentDAO.EVourcherId  = EVoucherContent.EVourcherId;
            EVoucherContentDAO.UsedCode     = EVoucherContent.UsedCode;
            EVoucherContentDAO.MerchantCode = EVoucherContent.MerchantCode;
            EVoucherContentDAO.UsedDate     = EVoucherContent.UsedDate;
            await DataContext.SaveChangesAsync();

            return(true);
        }
        public async Task <bool> Create(EVoucherContent EVoucherContent)
        {
            EVoucherContentDAO EVoucherContentDAO = new EVoucherContentDAO();

            EVoucherContentDAO.Id           = EVoucherContent.Id;
            EVoucherContentDAO.EVourcherId  = EVoucherContent.EVourcherId;
            EVoucherContentDAO.UsedCode     = EVoucherContent.UsedCode;
            EVoucherContentDAO.MerchantCode = EVoucherContent.MerchantCode;
            EVoucherContentDAO.UsedDate     = EVoucherContent.UsedDate;

            await DataContext.EVoucherContent.AddAsync(EVoucherContentDAO);

            await DataContext.SaveChangesAsync();

            EVoucherContent.Id = EVoucherContentDAO.Id;
            return(true);
        }
        public async Task <bool> ValidateId(EVoucherContent EVoucherContent)
        {
            EVoucherContentFilter EVoucherContentFilter = new EVoucherContentFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new LongFilter {
                    Equal = EVoucherContent.Id
                },
                Selects = EVoucherContentSelect.Id
            };

            int count = await UOW.EVoucherContentRepository.Count(EVoucherContentFilter);

            if (count == 0)
            {
                EVoucherContent.AddError(nameof(EVoucherContentValidator), nameof(EVoucherContent.Id), ErrorCode.IdNotExisted);
            }

            return(count == 1);
        }
        public async Task <EVoucherContent> Get(long Id)
        {
            EVoucherContent EVoucherContent = await DataContext.EVoucherContent.Where(x => x.Id == Id).Select(EVoucherContentDAO => new EVoucherContent()
            {
                Id           = EVoucherContentDAO.Id,
                EVourcherId  = EVoucherContentDAO.EVourcherId,
                UsedCode     = EVoucherContentDAO.UsedCode,
                MerchantCode = EVoucherContentDAO.MerchantCode,
                UsedDate     = EVoucherContentDAO.UsedDate,
                EVourcher    = EVoucherContentDAO.EVourcher == null ? null : new EVoucher
                {
                    Id         = EVoucherContentDAO.EVourcher.Id,
                    CustomerId = EVoucherContentDAO.EVourcher.CustomerId,
                    ProductId  = EVoucherContentDAO.EVourcher.ProductId,
                    Name       = EVoucherContentDAO.EVourcher.Name,
                    Start      = EVoucherContentDAO.EVourcher.Start,
                    End        = EVoucherContentDAO.EVourcher.End,
                    Quantity   = EVoucherContentDAO.EVourcher.Quantity,
                },
            }).FirstOrDefaultAsync();

            return(EVoucherContent);
        }
 public async Task <bool> Create(EVoucherContent EVoucherContent)
 {
     return(EVoucherContent.IsValidated);
 }