public async Task <ResultDto> AddPhoneModel(HW_PhoneModelInfo model)
 {
     return(new ResultDto()
     {
         Success = await _context.Add(model)
     });
 }
Esempio n. 2
0
        public async Task CreateOwner(CreateOwnerModel owner)
        {
            var address = new OwnerAddress
            {
                HouseNumber = owner.HouseNumber,
                StreetName  = owner.StreetName,
                City        = owner.City,
                County      = owner.County,
                PostCode    = owner.PostCode
            };

            var addressEntity = await _addressRepo
                                .GetAddress(owner.HouseNumber, owner.StreetName, owner.City, owner.County, owner.PostCode)
                                .SingleOrDefaultAsync();

            if (addressEntity == null)
            {
                addressEntity = Mapper.Map <ExampleOwnerAddress>(address);
                await _addressRepo.Add(addressEntity);
            }

            var entity = Mapper.Map <ExampleOwner>(owner);

            entity.Address = addressEntity;
            await _ownerRepo.Add(entity);
        }
Esempio n. 3
0
        public void AddCar(string carType, string civSeries, string bodySeries,
                           int carMileage, int yearOfManufacture, string itpValability,
                           string ownerFirstName, string ownerLastName,
                           string cNP)
        {
            var owner = ownerRepository.Add(new Owner()
            {
                Id        = Guid.NewGuid(),
                FirstName = ownerFirstName,
                LastName  = ownerLastName,
                CNP       = cNP
            });

            var car = carRepository.Add(new Car()
            {
                Id                = Guid.NewGuid(),
                CarType           = carType,
                CivSeries         = civSeries,
                BodySeries        = bodySeries,
                CarMileage        = carMileage,
                YearOfManufacture = yearOfManufacture,
                ItpValability     = itpValability,
                Owner             = owner,
            });
        }
Esempio n. 4
0
        public ActionResult AddOwnerView(ViewModelData viewModelData)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    OwnerAccount newAccount = viewModelData.owner;
                    if (!ownerRepository.CheckOwner(newAccount))
                    {
                        ownerRepository.Add(newAccount);

                        return(GoToMainOwnerView(newAccount.Id));
                    }
                }
                catch (Exception ex)
                {
                    //Add error
                    ViewBag.Message = ex;
                    return(View(viewModelData));
                }
            }

            ViewBag.Message = "Missing or Incorrect Data";
            return(View(viewModelData));
        }
Esempio n. 5
0
 public async Task <ResultDto> AddUser(UserLoginDto userLoginDto)
 {
     userLoginDto.ISNullOrEmpty();
     return(new ResultDto()
     {
         Success = await _context.Add(new HW_Users()
         {
             UserName = userLoginDto.UserName, UserPwd = userLoginDto.UserPwd
         })
     });
 }
Esempio n. 6
0
        public async Task <ActionResult> CreateOwner(CreateOwnerViewModel model)
        {
            if (ModelState.IsValid)
            {
                Owner owner = ParseCreateOwnerModelToOwner(model);
                await ownerRepository.Add(owner);

                return(RedirectToAction("Index", "Owner"));
            }
            return(View(model));
        }
Esempio n. 7
0
        public async Task <tblOwner> Add(tblOwner entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("Cannot add blank owner");
            }
            if (await _ownerRepository.GetByIdAsync(entity.Id).ConfigureAwait(false) != null)
            {
                throw new InvalidOperationException("Owner already exists.");
            }

            return(await _ownerRepository.Add(entity));
        }
Esempio n. 8
0
        private async Task <Owner> CreateOwnerAsync(IUser user)
        {
            var owner = new Owner(user);

            // Give some initial items for the new owner to start out with
            owner.GiveItem(ItemRef.Water, 10);
            owner.GiveItem(ItemRef.Tuna, 10);

            _ownerRepository.Add(owner);
            await _ownerRepository.SaveChangesAsync();

            return(owner);
        }
Esempio n. 9
0
        public async Task <AddPost> Add(AddPost entity)
        {
            try
            {
                var addedId = await productRepository.Add(entity);

                var result = await productRepository.GetById(addedId.ToString());

                return(result);
            }
            catch (Exception ex)
            {
                throw new RestException(System.Net.HttpStatusCode.NotFound, ex.Message);
            }
        }
Esempio n. 10
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)));
        }
Esempio n. 11
0
        public async Task <IActionResult> CreateOwner([FromBody] OwnerResource ownerResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var owner = await ownerRepository.FindOwner(ownerResource);

            if (owner != null)
            {
                ModelState.AddModelError("Message", "Owner creation error. Sorry, this owner already exists!");
                return(BadRequest(ModelState));
            }
            owner = mapper.Map <OwnerResource, Owner>(ownerResource);
            ownerRepository.Add(owner);
            await unitOfWork.CompleteAsync();

            return(Ok(owner));
        }
Esempio n. 12
0
        public OwnerEntity CreateOwner(string passportNumber, string firstName, string lastName, string email)
        {
            OwnerEntity existingOwner = ownerRepository.GetByPassportNumber(passportNumber)?.ToOwnerEntity();

            if (!ReferenceEquals(existingOwner, null))
            {
                if (existingOwner.FirstName.Equals(firstName, StringComparison.CurrentCultureIgnoreCase) && (existingOwner.LastName.Equals(lastName, StringComparison.CurrentCultureIgnoreCase)))
                {
                    return(existingOwner);
                }

                throw new InvalidOperationException($"The owner with passport number {passportNumber} already exists.");
            }

            Owner owner = new Owner(passportNumber.ToUpperInvariant(), firstName, lastName, email);

            ownerRepository.Add(owner.ToOwnerDTO());

            return(owner.ToOwnerEntity());
        }
Esempio n. 13
0
        public async Task <ResultDto> CreateEmailHistoryInfo(createEmailHistoryInfoDto createEmailHistoryInfoDto)
        {
            // 检测邮箱账号为否为QQ邮箱,并且是否正确
            string expression = AppConfigurtaionService.Configuration["EmailServicesStrings:EmailExpression"]; // 拿到配置文件中的正则表达式

            if (!Regex.IsMatch(createEmailHistoryInfoDto.RecipientId, expression, RegexOptions.Compiled))
            {
                // 请输入正确的QQ邮箱账号
                throw new Exception("Please enter the correct QQ email account.");
            }
            var emailHistory = ModelBindingService.CopyModel <HW_EmailHistoryInfo, createEmailHistoryInfoDto>(createEmailHistoryInfoDto);

            // 发送QQ邮件
            if (createEmailHistoryInfoDto.IsSendEmail)
            {
                emailHistory.EmailBody = _emailServices.SendRandomCodeQQEmail(emailHistory.RecipientId).RecipientBody;
            }
            return(new ResultDto()
            {
                Success = await _context.Add(emailHistory)
            });
        }
Esempio n. 14
0
 public void  addOWner(Owner owner)
 {
     _ownerRepository.Add(owner);
 }
Esempio n. 15
0
 public async Task <bool> RegisterOwner(Owner owner)
 {
     return(await _ownerRepository.Add(owner));
 }