Exemple #1
0
        public ResultDTO UpdateArea(int AreaId, BusinessEntities.AreaEntity AreaEntity)
        {
            var result = new ResultDTO {
                IsSuccess = false
            };

            if (AreaEntity != null)
            {
                var isExist = _unitOfWork.AreaRepository.GetManyQueryable(c => c.AreaName.ToLower() == AreaEntity.AreaName.ToLower() && c.CountryId == AreaEntity.CountryId && c.StateId == AreaEntity.StateId && c.CityId == AreaEntity.CityId && c.Pincode == AreaEntity.Pincode).Count() > 0;
                if (!isExist)
                {
                    using (var scope = new TransactionScope())
                    {
                        var Areaent = _unitOfWork.AreaRepository.GetByID(AreaId);
                        if (Areaent != null)
                        {
                            Areaent.AreaId     = AreaEntity.AreaId;
                            Areaent.AreaName   = AreaEntity.AreaName;
                            Areaent.StateId    = AreaEntity.StateId;
                            Areaent.Pincode    = AreaEntity.Pincode;
                            Areaent.CountryId  = AreaEntity.CountryId;
                            Areaent.CityId     = AreaEntity.CityId;
                            Areaent.IsActive   = AreaEntity.IsActive;
                            Areaent.ModifiedBy = AreaEntity.ModifiedBy;
                            Areaent.ModifiedOn = DateTime.Now;


                            _unitOfWork.AreaRepository.Update(Areaent);
                            _unitOfWork.Save();
                            scope.Complete();

                            result.IsSuccess = true;
                            result.Message   = "Updated Area Successfully";
                        }
                    }
                }
                else
                {
                    result.IsSuccess = false;
                    result.Message   = "Area name already exist";
                }
            }
            return(result);
        }
Exemple #2
0
        public ResultDTO CreateArea(BusinessEntities.AreaEntity AreaEntity)
        {
            var result = new ResultDTO {
                IsSuccess = false
            };

            var isExist = _unitOfWork.AreaRepository.GetManyQueryable(c => c.AreaName.ToLower() == AreaEntity.AreaName.ToLower() && c.CountryId == AreaEntity.CountryId && c.StateId == AreaEntity.StateId && c.CityId == AreaEntity.CityId).Count() > 0;

            if (!isExist)
            {
                using (var scope = new TransactionScope())
                {
                    var Area = new Area
                    {
                        AreaName   = AreaEntity.AreaName,
                        CityId     = AreaEntity.CityId,
                        StateId    = AreaEntity.StateId,
                        CountryId  = AreaEntity.CountryId,
                        Pincode    = AreaEntity.Pincode,
                        IsActive   = true,
                        CreatedBy  = AreaEntity.CreatedBy,
                        CreatedOn  = DateTime.Now,
                        ModifiedBy = AreaEntity.CreatedBy,
                        ModifiedOn = DateTime.Now,
                    };
                    _unitOfWork.AreaRepository.Insert(Area);
                    _unitOfWork.Save();
                    scope.Complete();

                    result.IsSuccess = true;
                    result.Message   = "Inserted Area Successfully";
                }
            }
            else
            {
                result.IsSuccess = false;
                result.Message   = "Area name already exist";
            }
            return(result);
        }