Beispiel #1
0
        private CemeteryAreasDTO LoadEntityData(CemeteryAreas entity)
        {
            var myDto = new CemeteryAreasDTO()
            {
                Id      = entity.Id,
                Name    = entity.Name,
                Alias   = entity.Alias,
                Remark  = entity.Remark,
                RowSort = entity.RowSort ?? "ASC"
            };

            myDto.TotalCount = _databaseContext.Tombstones.Count(a => a.AreaId == entity.Id);
            myDto.OrderCount = _databaseContext.Tombstones.Count(a => a.AreaId == entity.Id && a.PaymentStatusId == 2);
            myDto.SaleCount  = _databaseContext.Tombstones.Count(a => a.AreaId == entity.Id && a.PaymentStatusId == 3);
            myDto.BuryCount  = _databaseContext.Tombstones.Count(a => a.AreaId == entity.Id && a.PaymentStatusId == 5);

            return(myDto);
        }
Beispiel #2
0
        /// <summary>
        /// 新建墓碑区域
        /// </summary>
        /// <param name="csDto"></param>
        /// <returns></returns>
        public DataControlResult <CemeteryAreasDTO> Create(CemeteryAreasDTO csDto)
        {
            var result = new DataControlResult <CemeteryAreasDTO>();
            //判断是否为重复区域
            var repeat =
                _databaseContext.CemeteryAreas.FirstOrDefault(a => a.Name == csDto.Name || a.Alias == csDto.Alias);

            if (repeat != null)
            {
                result.code         = MyErrorCode.ResDBError;
                result.msg          = "重复的区域名或别名编号";
                result.success      = false;
                result.ResultOutDto = null;
                return(result);
            }
            try
            {
                #region 赋值
                var cemeteryAreas = new CemeteryAreas
                {
                    Alias   = csDto.Alias,
                    Name    = csDto.Name,
                    Remark  = csDto.Remark,
                    RowSort = csDto.RowSort
                };
                #endregion

                _databaseContext.CemeteryAreas.Add(cemeteryAreas);
                _databaseContext.SaveChanges();
                result.ResultOutDto = _cemeteryAreasMapper.Map(cemeteryAreas);
                result.code         = MyErrorCode.ResOK;
                result.msg          = string.Empty;
                result.success      = true;
            }
            catch (Exception ex)
            {
                result.code         = MyErrorCode.ResDBError;
                result.msg          = ex.Message;
                result.success      = false;
                result.ResultOutDto = null;
                return(result);
            }
            return(result);
        }
Beispiel #3
0
        public CemeteryAreasDTO Map(CemeteryAreas entity)
        {
            var dto = LoadEntityData(entity);

            return(dto);
        }