Esempio n. 1
0
        /// <summary>
        /// 续交管理费
        /// </summary>
        /// <param name="csDto"></param>
        /// <returns></returns>
        public DataControlResult <TombstoneDTO> RenewManageLimit(TombstoneDTO csDto)
        {
            var result = new DataControlResult <TombstoneDTO>();

            try
            {
                var tombstone = _databaseContext.Tombstones.SingleOrDefault(n => n.Id == csDto.Id);
                if (tombstone == null)
                {
                    result.success = false;
                    result.msg     = "该墓碑不存在";
                    result.code    = MyErrorCode.ResParamError;
                    return(result);
                }
                //判断该墓碑是否存在
                var repeatCol =
                    _databaseContext.Tombstones.FirstOrDefault(a => a.AreaId == csDto.AreaId &&
                                                               a.RowId == csDto.RowId &&
                                                               a.ColumnId == csDto.ColumnId);
                if (repeatCol != null && repeatCol.Id != csDto.Id)
                {
                    result.code         = MyErrorCode.ResDBError;
                    result.msg          = "该墓碑行号已存在";
                    result.success      = false;
                    result.ResultOutDto = null;
                    return(result);
                }
                #region 赋值
                //if (csDto.ExpiryDate != null) tombstone.ExpiryDate = (DateTime)csDto.ExpiryDate;
                tombstone.ExpiryDate   = tombstone.ExpiryDate.AddYears((int)csDto.ManageLimit);
                tombstone.ManageLimit += csDto.ManageLimit;

                #endregion
                _databaseContext.SaveChanges();
                result.ResultOutDto = _tombstoneMapper.Map(tombstone, false);
                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;
                return(result);
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 墓碑排序
        /// </summary>
        /// <param name="csDtoList"></param>
        /// <returns></returns>
        public DataControlResult <TombstoneDTO> SorTombstone(string[] idList)
        {
            var result = new DataControlResult <TombstoneDTO>();

            try
            {
                using (TransactionScope tsScope = new TransactionScope())
                {
                    var submitFlag = true;
                    for (int i = 0; i < idList.Length; i++)
                    {
                        TombstoneDTO dto = new TombstoneDTO
                        {
                            Id      = int.Parse(idList[i]),
                            SortNum = i
                        };
                        var tempRl = Update(dto);
                        if (!tempRl.success)
                        {
                            submitFlag = false;
                            result     = tempRl;
                        }
                    }
                    if (submitFlag)
                    {
                        tsScope.Complete();
                        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;
                return(result);
            }

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 新建墓碑
        /// </summary>
        /// <param name="csDto"></param>
        /// <returns></returns>
        public DataControlResult <TombstoneDTO> Create(TombstoneDTO csDto)
        {
            var result = new DataControlResult <TombstoneDTO>();
            //判断该墓碑是否存在
            var repeat =
                _databaseContext.Tombstones.FirstOrDefault(a => a.Name == csDto.Name);

            if (repeat != null)
            {
                result.code         = MyErrorCode.ResDBError;
                result.msg          = "该墓碑名称已存在";
                result.success      = false;
                result.ResultOutDto = null;
                return(result);
            }
            //判断该墓碑是否存在
            var repeatCol =
                _databaseContext.Tombstones.FirstOrDefault(a => a.AreaId == csDto.AreaId &&
                                                           a.RowId == csDto.RowId &&
                                                           a.ColumnId == csDto.ColumnId);

            if (repeatCol != null)
            {
                result.code         = MyErrorCode.ResDBError;
                result.msg          = "该墓碑行号已存在";
                result.success      = false;
                result.ResultOutDto = null;
                return(result);
            }
            try
            {
                #region 赋值
                var tombstone = new Tombstone
                {
                    Name         = csDto.Name,
                    Alias        = csDto.Alias,
                    Remark       = csDto.Remark,
                    CustomerName = csDto.CustomerName,
                    StoneText    = csDto.StoneText,
                    Width        = csDto.Width,
                    Height       = csDto.Height,
                    Acreage      = csDto.Width * csDto.Height,
                    Image        = csDto.Image,
                    SortNum      = csDto.SortNum,
                    SupperManage = 0,
                    ManageLimit  = 0
                };

                if (csDto.ExpiryDate != null)
                {
                    tombstone.ExpiryDate = (DateTime)csDto.ExpiryDate;
                }
                if (csDto.BuyDate != null)
                {
                    tombstone.BuyDate = (DateTime)csDto.BuyDate;
                }
                if (csDto.LastPaymentDate != null)
                {
                    tombstone.LastPaymentDate = (DateTime)csDto.LastPaymentDate;
                }
                if (csDto.BuryDate != null)
                {
                    tombstone.BuryDate = (DateTime)csDto.BuryDate;
                }

                if (csDto.AreaId.HasValue && csDto.AreaId > 0)
                {
                    tombstone.AreaId = (int)csDto.AreaId;
                }
                if (csDto.RowId.HasValue && csDto.RowId > 0)
                {
                    tombstone.RowId = (int)csDto.RowId;
                }
                if (csDto.ColumnId.HasValue && csDto.ColumnId > 0)
                {
                    tombstone.ColumnId = (int)csDto.ColumnId;
                }
                if (csDto.CustomerId.HasValue && csDto.CustomerId > 0)
                {
                    tombstone.CustomerId = (int)csDto.CustomerId;
                }
                if (csDto.SecurityLevelId.HasValue && csDto.SecurityLevelId > 0)
                {
                    tombstone.SecurityLevelId = (int)csDto.SecurityLevelId;
                }
                if (csDto.ServiceLevelId.HasValue && csDto.ServiceLevelId > 0)
                {
                    tombstone.ServiceLevelId = (int)csDto.ServiceLevelId;
                }
                if (csDto.TypeId.HasValue && csDto.TypeId > 0)
                {
                    tombstone.TypeId = (int)csDto.TypeId;
                }
                if (csDto.PaymentStatusId.HasValue && csDto.PaymentStatusId > 0)
                {
                    tombstone.PaymentStatusId = (int)csDto.PaymentStatusId;
                }
                if (csDto.ParentId.HasValue && csDto.ParentId > 0)
                {
                    tombstone.ParentId = (int)csDto.ParentId;
                }
                #endregion

                _databaseContext.Tombstones.Add(tombstone);
                _databaseContext.SaveChanges();
                result.ResultOutDto = _tombstoneMapper.Map(tombstone, false);
                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);
        }
Esempio n. 4
0
        /// <summary>
        /// 更新墓碑信息
        /// </summary>
        /// <param name="csDto"></param>
        /// <returns></returns>
        public DataControlResult <TombstoneDTO> Update(TombstoneDTO csDto)
        {
            var result = new DataControlResult <TombstoneDTO>();

            try
            {
                var tombstone = _databaseContext.Tombstones.SingleOrDefault(n => n.Id == csDto.Id);
                if (tombstone == null)
                {
                    result.success = false;
                    result.msg     = "该墓碑不存在";
                    result.code    = MyErrorCode.ResParamError;
                    return(result);
                }
                //判断该墓碑是否存在
                var repeatCol =
                    _databaseContext.Tombstones.FirstOrDefault(a => a.AreaId == csDto.AreaId &&
                                                               a.RowId == csDto.RowId &&
                                                               a.ColumnId == csDto.ColumnId);
                if (repeatCol != null && repeatCol.Id != csDto.Id)
                {
                    result.code         = MyErrorCode.ResDBError;
                    result.msg          = "该墓碑行号已存在";
                    result.success      = false;
                    result.ResultOutDto = null;
                    return(result);
                }
                #region 赋值

                if (csDto.Name != null)
                {
                    tombstone.Name = csDto.Name;
                }
                if (csDto.Alias != null)
                {
                    tombstone.Alias = csDto.Alias;
                }
                if (csDto.Remark != null)
                {
                    tombstone.Remark = csDto.Remark;
                }
                if (csDto.CustomerName != null)
                {
                    tombstone.CustomerName = csDto.CustomerName;
                }
                if (csDto.StoneText != null)
                {
                    tombstone.StoneText = csDto.StoneText;
                }
                if (csDto.Image != null)
                {
                    tombstone.Image = csDto.Image;
                }
                tombstone.Width   = csDto.Width;
                tombstone.Height  = csDto.Height;
                tombstone.Acreage = csDto.Width * csDto.Height;
                tombstone.Image   = csDto.Image;
                tombstone.SortNum = csDto.SortNum;

                if (csDto.ExpiryDate != null)
                {
                    tombstone.ExpiryDate = (DateTime)csDto.ExpiryDate;
                }
                if (csDto.BuyDate != null)
                {
                    tombstone.BuyDate = (DateTime)csDto.BuyDate;
                }
                if (csDto.LastPaymentDate != null)
                {
                    tombstone.LastPaymentDate = (DateTime)csDto.LastPaymentDate;
                }
                if (csDto.BuryDate != null)
                {
                    tombstone.BuryDate = (DateTime)csDto.BuryDate;
                }
                if (csDto.AreaId.HasValue && csDto.AreaId > 0)
                {
                    tombstone.AreaId = (int)csDto.AreaId;
                }
                if (csDto.RowId.HasValue && csDto.RowId > 0)
                {
                    tombstone.RowId = (int)csDto.RowId;
                }
                if (csDto.ColumnId.HasValue && csDto.ColumnId > 0)
                {
                    tombstone.ColumnId = (int)csDto.ColumnId;
                }
                if (csDto.CustomerId.HasValue && csDto.CustomerId > 0)
                {
                    tombstone.CustomerId = (int)csDto.CustomerId;
                }
                if (csDto.SecurityLevelId.HasValue && csDto.SecurityLevelId > 0)
                {
                    tombstone.SecurityLevelId = (int)csDto.SecurityLevelId;
                }
                if (csDto.ServiceLevelId.HasValue && csDto.ServiceLevelId > 0)
                {
                    tombstone.ServiceLevelId = (int)csDto.ServiceLevelId;
                }
                if (csDto.TypeId.HasValue && csDto.TypeId > 0)
                {
                    tombstone.TypeId = (int)csDto.TypeId;
                }
                if (csDto.PaymentStatusId.HasValue && csDto.PaymentStatusId > 0)
                {
                    tombstone.PaymentStatusId = (int)csDto.PaymentStatusId;
                }
                if (csDto.ParentId.HasValue && csDto.ParentId > 0)
                {
                    tombstone.ParentId = (int)csDto.ParentId;
                }

                #endregion
                _databaseContext.SaveChanges();
                result.ResultOutDto = _tombstoneMapper.Map(tombstone, false);
                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;
                return(result);
            }
            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// 批量添加墓碑
        /// </summary>
        /// <param name="areaId"></param>
        /// <param name="rowId"></param>
        /// <param name="typeId"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public DataControlResult <TombstoneDTO> CreateList(int areaId, int rowId, int typeId, int count)
        {
            var result     = new DataControlResult <TombstoneDTO>();
            var submitFlag = true;
            //获取当前区域,行所有的墓碑
            var hadTombstones = _databaseContext.Tombstones.Where(a => a.AreaId == areaId && a.RowId == rowId);
            var satrIndex     = 1;

            if (hadTombstones.Any())
            {
                var hadTombstone = hadTombstones.Max(a => a.ColumnId);
                satrIndex = hadTombstone + 1;
            }
            var endIndex = satrIndex + count;

            if (endIndex > 99)
            {
                endIndex = 99;
            }
            using (TransactionScope tsScope = new TransactionScope())
            {
                for (int i = satrIndex; i < endIndex; i++)
                {
                    var area = _databaseContext.CemeteryAreas.FirstOrDefault(a => a.Id == areaId);
                    var dto  = new TombstoneDTO
                    {
                        Name            = area.Name + rowId + "排" + i + "号",
                        Alias           = area.Name + rowId + "排" + i + "号",
                        AreaId          = areaId,
                        RowId           = rowId,
                        ColumnId        = i,
                        SortNum         = -1,
                        TypeId          = typeId,
                        BuryDate        = DateTime.Parse("1777-01-01"),
                        BuyDate         = DateTime.Parse("1777-01-01"),
                        ExpiryDate      = DateTime.Parse("1777-01-01"),
                        LastPaymentDate = DateTime.Parse("1777-01-01"),
                        SecurityLevelId = 1,
                        ServiceLevelId  = 1,
                        PaymentStatusId = 1
                    };
                    var resultTemp = Create(dto);
                    result.ResultOutDtos.Add(resultTemp.ResultOutDto);
                    if (!resultTemp.success)
                    {
                        submitFlag          = false;
                        result.code         = MyErrorCode.ResDBError;
                        result.msg          = "墓碑批量添加失败";
                        result.success      = false;
                        result.ResultOutDto = null;
                    }
                }
                if (submitFlag)
                {
                    tsScope.Complete();
                    result.code    = MyErrorCode.ResOK;
                    result.msg     = string.Empty;
                    result.success = true;
                }
                //result.ResultOutDtos.Add(_tombstoneMapper.Map(tombstoneBuriedPeopleMap, false));
            }
            return(result);
        }
Esempio n. 6
0
        private TombstoneDTO LoadEntityData(Tombstone entity, bool includeAll)
        {
            var myDto = new TombstoneDTO()
            {
                Id               = entity.Id,
                Name             = entity.Name,
                AreaId           = entity.AreaId,
                RowId            = entity.RowId,
                ColumnId         = entity.ColumnId,
                ParentId         = entity.ParentId,
                Alias            = entity.Alias,
                Remark           = entity.Remark,
                CustomerId       = entity.CustomerId,
                CustomerName     = entity.CustomerName,
                StoneText        = entity.StoneText,
                ExpiryDate       = entity.ExpiryDate,
                BuyDate          = entity.BuyDate,
                LastPaymentDate  = entity.LastPaymentDate,
                BuryDate         = entity.BuryDate,
                Width            = entity.Width,
                Height           = entity.Height,
                Acreage          = entity.Acreage,
                SecurityLevelId  = entity.SecurityLevelId,
                Image            = entity.Image,
                ServiceLevelId   = entity.ServiceLevelId,
                TypeId           = entity.TypeId,
                PaymentStatusId  = entity.PaymentStatusId,
                SortNum          = entity.SortNum,
                CustomerBuryDtos = new List <CustomerDTO>(),
                AreaSort         = "DESC",
                SupperManage     = entity.SupperManage,
                ManageLimit      = entity.ManageLimit
            };

            //包括所有关系
            if (includeAll)
            {
                if (entity.AreaId > 0)
                {
                    var cemeteryAreas = _databaseContext.CemeteryAreas.AsNoTracking().FirstOrDefault(a => a.Id == entity.AreaId);
                    CemeteryAreasDTO cemeteryAreasDto = null;
                    if (cemeteryAreas != null)
                    {
                        cemeteryAreasDto = new CemeteryAreasDTO
                        {
                            Id      = cemeteryAreas.Id,
                            Name    = cemeteryAreas.Name,
                            Alias   = cemeteryAreas.Alias,
                            Remark  = cemeteryAreas.Remark,
                            RowSort = cemeteryAreas.RowSort ?? "ASC"
                        };
                    }
                    myDto.AreaEntity = cemeteryAreasDto;
                    myDto.AreaSort   = cemeteryAreasDto.RowSort;
                }

                if (entity.RowId > 0)
                {
                    var             rows    = _databaseContext.CemeteryRows.AsNoTracking().FirstOrDefault(a => a.Id == entity.RowId);
                    CemeteryRowsDTO rowsDto = null;
                    if (rows != null)
                    {
                        rowsDto = new CemeteryRowsDTO
                        {
                            Id     = rows.Id,
                            Name   = rows.Name,
                            Alias  = rows.Alias,
                            Remark = rows.Remark
                        };
                    }
                    myDto.RowEntity = rowsDto;
                }
                if (entity.ColumnId > 0)
                {
                    var cols = _databaseContext.CemeteryColumns.AsNoTracking().FirstOrDefault(a => a.Id == entity.ColumnId);
                    CemeteryColumnsDTO closDto = null;
                    if (cols != null)
                    {
                        closDto = new CemeteryColumnsDTO
                        {
                            Id     = cols.Id,
                            Name   = cols.Name,
                            Alias  = cols.Alias,
                            Remark = cols.Remark
                        };
                    }
                    myDto.ColumnEntity = closDto;
                }
                if (entity.PaymentStatusId > 0)
                {
                    var paymentStatus = _databaseContext.PaymentStatus.AsNoTracking().FirstOrDefault(a => a.Id == entity.PaymentStatusId);
                    PaymentStatusDTO paymentStatusDto = null;
                    if (paymentStatus != null)
                    {
                        paymentStatusDto = new PaymentStatusDTO
                        {
                            Id     = paymentStatus.Id,
                            Name   = paymentStatus.Name,
                            Alias  = paymentStatus.Alias,
                            Remark = paymentStatus.Remark
                        };
                    }
                    myDto.PaymentStatusEntity = paymentStatusDto;
                }
                if (entity.SecurityLevelId > 0)
                {
                    var securityLevels = _databaseContext.SecurityLevels.AsNoTracking().FirstOrDefault(a => a.Id == entity.SecurityLevelId);
                    if (securityLevels != null)
                    {
                        myDto.SecurityLevelName = securityLevels.Name;
                    }
                }
                if (entity.ServiceLevelId > 0)
                {
                    var serviceLevels = _databaseContext.ServiceLevels.AsNoTracking().FirstOrDefault(a => a.Id == entity.ServiceLevelId);
                    if (serviceLevels != null)
                    {
                        myDto.ServiceLevelName = serviceLevels.Name;
                    }
                }

                //装载该墓碑落葬人
                var tombstoneBuriedPeopleMaps = _databaseContext.TombstoneBuriedPeopleMaps.Where(a => a.TombstoneId == myDto.Id);
                foreach (var tombstoneBuriedPeopleMap in tombstoneBuriedPeopleMaps)
                {
                    var customer = _databaseContext.Customers.FirstOrDefault(a => a.Id == tombstoneBuriedPeopleMap.BuriedCustomerId);
                    if (customer != null)
                    {
                        var customerDto = new CustomerDTO
                        {
                            Id         = customer.Id,
                            FirstName  = customer.FirstName,
                            MiddleName = customer.MiddleName,
                            LastName   = customer.LastName
                        };
                        myDto.CustomerBuryDtos.Add(customerDto);
                    }
                }
            }

            return(myDto);
        }