示例#1
0
 public static Owner FromDto(OwnerDto dto)
 {
     return(new Owner
     {
         Active = dto.Active.ActiveToBool(),
         Id = dto.Id,
         Location = dto.Location,
         Name = dto.Location
     });
 }
        public async Task <IActionResult> UpdateOwner(int id, OwnerDto owner)
        {
            owner.Id = id;

            var updatedOwner = await _ownerService.UpdateAsync(owner);

            var response = new ApiResponse <OwnerDto>(updatedOwner);

            return(Ok(response));
        }
示例#3
0
        public void AddOwner(OwnerDto ownerDto)
        {
            Owner owner = new Owner()
            {
                Name = ownerDto.Name
            };

            dataBase.OwnerRepository.Create(owner);
            dataBase.Save();
        }
示例#4
0
        public async Task <OwnerDto> UpdateOwnerAsync(Guid ownerId, OwnerDto owner)
        {
            var dbOwner = await this.repo.Owners.GetByIdAsync(ownerId);

            dbOwner.Name    = owner.Name;
            dbOwner.Address = owner.Address;
            await this.repo.SaveChangesAsync();

            return(dbOwner.Convert());
        }
示例#5
0
        private async Task <bool> OnDelete(GuoGuoCommunityContext db, OwnerDto dto, CancellationToken token = default)
        {
            //业主认证申请信息
            if (await db.OwnerCertificationRecords.Where(x => x.OwnerId.ToString() == dto.Id && x.IsDeleted == false).FirstOrDefaultAsync(token) != null)
            {
                return(true);
            }

            return(false);
        }
示例#6
0
        public async Task <OwnerDto> CreateOwnerAsync(OwnerDto owner)
        {
            var dataModel = owner.Convert();

            await this.repo.Owners.AddAsync(dataModel);

            await this.repo.SaveChangesAsync();

            return(dataModel.Convert());
        }
示例#7
0
        public async Task <OwnerDto> UpdateAsync(OwnerDto ownerDto)
        {
            var currentOwner = await _ownerRepository.GetByIdAsync(ownerDto.Id);

            _mapper.Map(ownerDto, currentOwner);
            await _ownerRepository.UpdateAsync(currentOwner);

            ownerDto = _mapper.Map <OwnerDto>(currentOwner);

            return(ownerDto);
        }
        private async Task UpdateAddress(Owner ownerToUpdate, OwnerDto ownerDto)
        {
            var countOfPeopleAtAddress = await _repo.PeopleForAddress(ownerToUpdate.Address.Id);

            if (countOfPeopleAtAddress == 1)
            {
                _repo.DeleteAddress(ownerToUpdate.Address);
            }

            await AddAddress(ownerToUpdate, ownerDto);
        }
示例#9
0
        public async Task <OwnerDto> UpdateAsync(OwnerDto owner)
        {
            var currentOwner = await GetEntityByIdAsync(owner.Id);

            var newOwner = owner.MapTo <OwnerDto>();

            OwnerPropertyDbContext.Entry(currentOwner).CurrentValues.SetValues(newOwner);
            await SaveChangesAsync();

            return(newOwner.MapTo <OwnerDto>());
        }
示例#10
0
        public long Add(OwnerDto dto)
        {
            if (dto == null)
            {
                throw new ArgumentNullException("dto");
            }

            using (var db = DBManager.GetInstance())
            {
                return(db.Insertable <T_Owner>(dto).ExecuteReturnIdentity());
            }
        }
示例#11
0
文件: Create.cs 项目: dev027/Dealing
        /// <inheritdoc />
        public void CreateOwner(IOwner owner)
        {
            OwnerDto ownerDto = OwnerDto.ToDto(owner);

            this.Context.Owners.Add(ownerDto);
            int count = this.Context.SaveChanges();

            if (count != 1)
            {
                throw new ApplicationException($"Unexpectedly created {count} rows");
            }
        }
示例#12
0
        public IHttpActionResult Add([FromBody] OwnerDto owner)
        {
            try
            {
                _sqlDA.SaveData <OwnerDto>("dbo.spOwners_Add", owner);

                return(StatusCode(HttpStatusCode.Created));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
示例#13
0
        public async Task <IActionResult> PostOwner([FromBody] OwnerDto ownerDto)
        {
            var result = await _repository.CreateOwner(ownerDto);

            if (result.Item1 != null)
            {
                return(Ok(new { id = result.Item1.Id, UserName = result.Item1.User.Username }));
            }
            else
            {
                return(BadRequest(new { message = $"error creating user: {result.Item2}" }));
            }
        }
        public void AddNewProduct(ProductTypeDto type, OwnerDto owner, ProductStatusDto status, ZoneDto zone, string description)
        {
            ProductDto productDto = new ProductDto
            {
                Description = description,
                Id          = SelectedProduct.ProductId,
                Owner       = owner,
                Status      = status,
                Type        = type,
                Zone        = zone
            };

            SaveOrUpdateProduct(productDto);
        }
示例#15
0
        private void ValidateOwner(OwnerDto ownerDto, long tenantId)
        {
            foreach (var name in ownerDto.TitleDictionary)
            {
                if (name.Value.Length > 300)
                {
                    throw new ValidationException(ErrorCodes.MenuNameExceedLength);
                }

                if (_typeTranslationService.CheckNameExist(name.Value, name.Key, ownerDto.OwnerId, tenantId))
                {
                    throw new ValidationException(ErrorCodes.NameIsExist);
                }
            }
        }
示例#16
0
        public ActionResult DeleteConfirm(int id)
        {
            string url = "OwnerData/GetOwner/" + id;
            HttpResponseMessage httpResponse = client.GetAsync(url).Result;

            if (httpResponse.IsSuccessStatusCode)
            {
                OwnerDto SelectedOwner = httpResponse.Content.ReadAsAsync <OwnerDto>().Result;
                return(View(SelectedOwner));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
示例#17
0
        public async Task <OwnerDto> InsertAsync(OwnerDto ownerDto)
        {
            var existingOwner = await GetByIdendtificationNumberAsync(ownerDto.IdentificationNumber);

            if (existingOwner != null)
            {
                throw new RealEstateException($"Owner with identification number '{ownerDto.IdentificationNumber}' already exists.");
            }

            var owner = _mapper.Map <Owner>(ownerDto);
            await _ownerRepository.InsertAsync(owner);

            ownerDto = _mapper.Map <OwnerDto>(owner);

            return(ownerDto);
        }
示例#18
0
        public void should_mapping_owner_with_mapping_logic_for_common_type()
        {
            var config = TypeAdapterConfig <OwnerDto, Owner> .NewConfig()
                         .Map(dest => dest.FirstName, src => src.FullName)
                         .Map(dest => dest.LastName, src => src.FullName)
                         .AddDestinationTransform((string x) => x.ToUpper())
                         .Config;

            var ownerDto = new OwnerDto {
                Id = _ownerId.ToString(), FullName = "zhangsan"
            };
            var owner = ownerDto.Adapt <Owner>(config);

            owner.FirstName.ShouldBe("ZHANGSAN", Case.Sensitive);
            owner.LastName.ShouldBe("ZHANGSAN", Case.Sensitive);
        }
示例#19
0
        public async void PutOwner()
        {
            using (MyProfileDbContext context = new MyProfileDbContext(_dbContextOptions))
            {
                IMapper mapper = CreateMapperConfig();

                MyProfileController myProfileController = new MyProfileController(mapper, new OwnerRepository(context), new AddressRepository(context), new ContactRepository(context), new ExperienceRepository(context));

                for (int i = 0; i < 10; ++i)
                {
                    OwnerDto owner = new OwnerDto()
                    {
                        DateBirth = DateTime.Now,
                        FirstName = $"Test{i}",
                        LastName  = $"{i}Test"
                    };

                    myProfileController.PostOwner(owner);
                }
            }

            using (MyProfileDbContext context = new MyProfileDbContext(_dbContextOptions))
            {
                IMapper mapper = CreateMapperConfig();

                MyProfileController myProfileController = new MyProfileController(mapper, new OwnerRepository(context), new AddressRepository(context), new ContactRepository(context), new ExperienceRepository(context));

                IActionResult getResult = await myProfileController.GetOwner(3);

                OkObjectResult okResult = getResult as OkObjectResult;
                OwnerDto       ownerDto = okResult.Value as OwnerDto;
                ownerDto.FirstName += "Updated";

                IActionResult result = await myProfileController.PutOwner(3, ownerDto);

                NoContentResult noContentResult = result as NoContentResult;

                IActionResult updatedResult = await myProfileController.GetOwner(3);

                okResult = updatedResult as OkObjectResult;
                OwnerDto ownerDtoUpdated = okResult.Value as OwnerDto;

                Assert.NotNull(noContentResult);
                Assert.Equal(204, noContentResult.StatusCode);
                Assert.Equal("Test2Updated", ownerDtoUpdated.FirstName);
            }
        }
        public void PopulateOwnerFromDocument()
        {
            var list = new List <LegalPartyDocumentDto>
            {
                new LegalPartyDocumentDto
                {
                    LegalPartyRoleId      = 18,
                    GrmEventId            = 1,
                    DocNumber             = "foodocnum1",
                    LegalPartyDisplayName = "fooname1",
                    DocType = "footype1",
                    PctGain = 40
                },
                new LegalPartyDocumentDto
                {
                    LegalPartyRoleId      = 11,
                    GrmEventId            = 1,
                    DocNumber             = "foodocnum2",
                    LegalPartyDisplayName = "fooname2",
                    DocType = "footype2",
                    PctGain = 10
                },
                new LegalPartyDocumentDto
                {
                    LegalPartyRoleId      = 12,
                    GrmEventId            = 1,
                    DocNumber             = "foodocnum3",
                    LegalPartyDisplayName = "fooname3",
                    DocType = "footype3",
                    PctGain = 60
                }
            };

            var bvsOwner = new BaseValueSegmentOwnerDto()
            {
                LegalPartyRoleId = 12,
                GRMEventId       = 1
            };

            var owner = new OwnerDto();

            list.PopulateOwner(owner, bvsOwner);
            owner.BeneficialInterest.ShouldBe("fooname3");
            owner.DocNumber.ShouldBe("foodocnum3");
            owner.DocType.ShouldBe("footype3");
            owner.PercentageInterestGain.ShouldBe(60);
        }
示例#21
0
        public async Task <Tuple <Petowner, string> > CreateOwner(OwnerDto ownerDto)
        {
            using (var trans = await _dbContext.Database.BeginTransactionAsync())
            {
                try
                {
                    var pets = new List <Pet>();
                    foreach (var pet in ownerDto.Pets)
                    {
                        pets.Add(new Pet {
                            Name = pet.Name, Race = pet.Race, DateCreated = DateTime.UtcNow, Age = pet.Age, Size = pet.Size, Description = pet.Description, Photos = pet.Photos
                        });
                    }

                    var owner = new Petowner
                    {
                        User = _userService.CreateUser(new Entities.User
                        {
                            Username    = ownerDto.Email,
                            Role        = Role.Petowner,
                            FirstName   = ownerDto.Name,
                            LastName    = ownerDto.LastName,
                            Province    = ownerDto.Province,
                            Canton      = ownerDto.Canton,
                            Email       = ownerDto.Email,
                            Email2      = ownerDto.Email2,
                            Mobile      = ownerDto.Mobile,
                            DateCreated = DateTime.UtcNow,
                            Description = ownerDto.Description,
                            Photo       = ownerDto.Photo
                        }, ownerDto.Password),
                        Pets = pets
                    };
                    _dbContext.Owners.Add(owner);
                    await _dbContext.SaveChangesAsync();

                    trans.Commit();
                    return(new Tuple <Petowner, string>(owner, "success"));
                }
                catch (DbUpdateException e)
                {
                    trans.Rollback();
                    return(new Tuple <Petowner, string>(null, e.InnerException.Message));
                }
            }
        }
        public async Task <IActionResult> CarOwnersDownload(string carreg)
        {
            OwnerDto response = null;
            string   res      = string.Empty;
            var      temp     = await carDetailsBusinessLogic.CarOwnersDownloadAsync(carreg);

            if (temp != null)
            {
                response = temp;
            }
            else
            {
                return(Ok("Download Link expire or you have not submit the Request"));
            }

            return(Ok(response));
        }
示例#23
0
        public IActionResult Register([FromBody] OwnerDto ownerDto)
        {
            // map dto to entity
            var owner = _mapper.Map <Owner>(ownerDto);

            try
            {
                // save
                _userService.Create(owner, ownerDto.Password);
                return(Ok());
            }
            catch (Exception ex)
            {
                // return error message if there was an exception
                return(BadRequest(new { message = ex.Message }));
            }
        }
示例#24
0
        public static void PopulateEvent(this List <GrmEventInformationDto> events, OwnerDto ownerDto, int?grmEventId)
        {
            // per meeting  with bob do not error out if grm even information is missing, return unknown
            var grmEventInformationDto = events.FirstOrDefault(grm => grm.GrmEventId == grmEventId);

            if (grmEventInformationDto != null)
            {
                ownerDto.EventName = grmEventInformationDto.Description;
                ownerDto.EventType = grmEventInformationDto.EventType;
                ownerDto.EventDate = grmEventInformationDto.EffectiveDate;
            }
            else
            {
                ownerDto.EventName = Constants.EventUnknownName;
                ownerDto.EventType = Constants.EventUnknownName;
                ownerDto.EventDate = null;
            }
        }
示例#25
0
        public IEnumerable <OwnerDto> GetOwners()
        {
            List <Owner>    Owners    = db.Owners.ToList();
            List <OwnerDto> OwnerDtos = new List <OwnerDto> {
            };

            foreach (var Owner in Owners)
            {
                OwnerDto NewOwner = new OwnerDto
                {
                    OwnerID        = Owner.OwnerID,
                    OwnerFirstName = Owner.OwnerFirstName,
                    OwnerLastName  = Owner.OwnerLastName
                };
                OwnerDtos.Add(NewOwner);
            }
            return(OwnerDtos);
        }
示例#26
0
        public IActionResult PostOwner([FromBody] OwnerDto ownerDto)
        {
            if (ownerDto == null)
            {
                return(BadRequest());
            }

            Owner owner = _mapper.Map <OwnerDto, Owner>(ownerDto);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Owner result = _ownerRepository.Add(owner);

            return(CreatedAtRoute("GetOwner", new { id = result.ID }, _mapper.Map <Owner, OwnerDto>(result)));
        }
示例#27
0
 private void AddProperty(string addres, string neighborhood, OwnerDto owner,
                          PropertyTypeDto propertype, decimal price, int rooms, int square, int stratum)
 {
     _dataContext.Properties.Add(new PropertyDto
     {
         Address       = addres,
         Neighborhood  = neighborhood,
         Owner         = owner,
         HasParkingLot = false,
         Price         = price,
         IsAvailable   = true,
         Rooms         = rooms,
         SquareMeters  = square,
         Stratum       = stratum,
         PropertyType  = propertype,
         Remarks       = ""
     });
 }
        public async Task <IActionResult> UpdateOwner(int id, OwnerDto ownerDto)
        {
            if (ownerDto.Id != id)
            {
                return(BadRequest());
            }

            Owner ownerToUpdate = await _repo.GetOwnerById(id);

            ownerToUpdate = _mapper.Map(ownerDto, ownerToUpdate);

            var userIdFromClaims = User.Claims.FirstOrDefault().Value;

            if (Int32.TryParse(userIdFromClaims, out int currentUser))
            {
                ownerToUpdate.ModifiedBy = currentUser;
            }
            else
            {
                ownerToUpdate.ModifiedBy = 0;
            }

            if (ownerToUpdate.Address.AddressLine1 != ownerDto.AddressLine1 ||
                ownerToUpdate.Address.AddressLine2 != ownerDto.AddressLine2 ||
                ownerToUpdate.Address.AddressLine3 != ownerDto.AddressLine3 ||
                ownerToUpdate.Address.Postcode != ownerDto.Postcode ||
                ownerToUpdate.Address.Country != ownerDto.Country)
            {
                await UpdateAddress(ownerToUpdate, ownerDto);
            }

            ownerToUpdate.ModifiedDate = DateTime.Now;


            var ownerUpdatedSuccess = await _repo.Commit();

            if (!ownerUpdatedSuccess)
            {
                return(StatusCode(500));
            }

            return(NoContent());
        }
示例#29
0
        /// <summary>
        /// Method to Download Report for Car Owner after requesting
        /// </summary>
        /// <param name="carReg"></param>
        /// <returns></returns>
        public async Task <OwnerDto> CarOwnersDownloadAsync(string carReg)
        {
            OwnerDto response = null;
            var      caheData = _cache.Get(carReg);
            await Task.Run(() => {
                if (caheData != null)
                {
                    foreach (var data in caheData.TestData)
                    {
                        if (data.CarRegNumber.Equals(carReg))
                        {
                            response = data.Owner;
                        }
                    }
                }
            });

            return(response);
        }
示例#30
0
        public async Task UpdateForLegalizeAsync(OwnerDto dto, CancellationToken token = default)
        {
            using (var db = new GuoGuoCommunityContext())
            {
                if (!Guid.TryParse(dto.Id, out var uid))
                {
                    throw new NotImplementedException("业主信息不正确!");
                }
                var owner = await db.Owners.Where(x => x.Id == uid).FirstOrDefaultAsync(token);

                if (owner == null)
                {
                    throw new NotImplementedException("该业主不存在!");
                }
                owner.OwnerCertificationRecordId = dto.OwnerCertificationRecordId;
                owner.IsLegalize = true;
                owner.Name       = dto.Name;
                await db.SaveChangesAsync(token);
            }
        }