Ejemplo n.º 1
0
        /// <summary>
        /// Kiểm tra thêm mới hay cập nhật.
        /// </summary>
        /// <param name="input">Đầu vào.</param>
        public async Task CreateOrEdit(DemoCreateInput input)
        {
            // check null input
            if (input == null)
            {
                throw new UserFriendlyException(StringResources.NullParameter);
            }

            input.Ma                = GlobalFunction.RegexFormat(input.Ma);
            input.Ten               = GlobalFunction.RegexFormat(input.Ten);
            input.DateBasic         = GlobalFunction.GetDateTime(input.DateBasic);
            input.DateTime          = GlobalFunction.GetDateTime(input.DateTime);
            input.DateDisable       = GlobalFunction.GetDateTime(input.DateDisable);
            input.DateMinMax        = GlobalFunction.GetDateTime(input.DateMinMax);
            input.DateFrom          = GlobalFunction.GetDateTime(input.DateFrom);
            input.DateTo            = GlobalFunction.GetDateTime(input.DateTo);
            input.DateMultipleMonth = GlobalFunction.GetDateTime(input.DateMultipleMonth);
            input.MonthOnly         = GlobalFunction.GetDateTime(input.MonthOnly);

            // nếu là thêm mới
            if (input.Id == null)
            {
                await this.Create(input);
            }
            else
            {
                // là cập nhật
                await this.Update(input);
            }
        }
Ejemplo n.º 2
0
        private async Task Update(DemoCreateInput input)
        {
            var update = await this.demoRepository.GetAsync((int)input.Id);

            await this.demoFileRepository.DeleteAsync(w => w.DemoId == input.Id);

            this.ObjectMapper.Map(input, update);
        }
Ejemplo n.º 3
0
        private async Task Create(DemoCreateInput input)
        {
            var create = this.ObjectMapper.Map <Demo>(input);

            await this.demoRepository.InsertAsync(create);
        }