Example #1
0
        public async Task OnRecordEditConfirm()
        {
            #region 進行 Form Validation 檢查驗證作業
            if (LocalEditContext.Validate() == false)
            {
                return;
            }
            #endregion

            #region 檢查資料完整性
            #endregion

            if (IsShowEditRecord == true)
            {
                if (isNewRecordMode == true)
                {
                    await CurrentService.AddAsync(mapper.Map <Person>(CurrentRecord));

                    dataGrid.RefreshGrid();
                }
                else
                {
                    await CurrentService.UpdateAsync(mapper.Map <Person>(CurrentRecord));

                    dataGrid.RefreshGrid();
                }
                IsShowEditRecord = false;
            }
        }
Example #2
0
        public async Task OnRecordEditConfirm()
        {
            #region 進行 Form Validation 檢查驗證作業
            if (LocalEditContext.Validate() == false)
            {
                return;
            }
            #endregion

            #region 檢查資料完整性
            var checkKindDateResult = CurrentRecord.CheckKindDate();
            if (string.IsNullOrEmpty(checkKindDateResult) == false)
            {
                MessageBox.Show("400px", "200px", "警告", checkKindDateResult);
                return;
            }
            #endregion

            if (IsShowEditRecord == true)
            {
                if (isNewRecordMode == true)
                {
                    await CurrentService.AddAsync(mapper.Map <Person>(CurrentRecord));

                    Grid.Refresh();
                }
                else
                {
                    await CurrentService.UpdateAsync(mapper.Map <Person>(CurrentRecord));

                    Grid.Refresh();
                }
                IsShowEditRecord = false;
            }
        }
Example #3
0
 public async Task <ActionResult> Add(PersonDTO person)
 {
     if (ModelState.IsValid)
     {
         return(new OkObjectResult(await personsService.AddAsync(person)));
     }
     return(new BadRequestResult());
 }
Example #4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            await personService.AddAsync(Person);

            return(RedirectToPage("./List"));
        }
        public async Task <IActionResult> Post([FromBody] Person person)
        {
            if (person == null || person.Id != 0)
            {
                return(BadRequest());
            }

            await _personService.AddAsync(person);

            return(CreatedAtRoute("GetPerson", new { id = person.Id }, person));
        }
Example #6
0
        public async Task <IActionResult> Add(PersonAddOrUpdateInput person)
        {
            var personDto = new PersonDTO()
            {
                Name = person.Name,
                Age  = person.Age
            };

            await _personService.AddAsync(personDto);

            return(Redirect("/Home/Index"));
        }
        //
        // Summary:
        //     /// Method responsible for initializing the schema. ///
        //
        // Parameters:
        //   personService:
        //     The personService param.
        //
        public PersonMutationType(IPersonService personService)
        {
            Name        = "UserMutation";
            Description = "User Mutation Type";

            FieldAsync <PersonType>(
                name: "createPerson",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <PersonInputType> > {
                Name = "data"
            }
                    ),
                resolve: async context =>
            {
                PersonCommand data = context.GetArgument <PersonCommand>("data");

                Person result = await personService.AddAsync(data);

                if (personService.ValidationResult().IsValid is true)
                {
                    return(result);
                }

                context.Errors.AddRange(personService.ValidationResult().Errors.Select(x => new ExecutionError(x.ErrorMessage)));

                return(null);
            }
                );

            FieldAsync <BooleanGraphType>(
                name: "removePerson",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                await personService.RemoveAsync(id);

                if (personService.ValidationResult().IsValid is true)
                {
                    return(true);
                }

                context.Errors.AddRange(personService.ValidationResult().Errors.Select(x => new ExecutionError(x.ErrorMessage)));

                return(null);
            }
                );
        }
Example #8
0
        public async Task <ActionResult> CreateAsync([FromBody] PersonCreateModel person)
        {
            try
            {
                await _personService.AddAsync(person);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(ErrorResponse(ex));
            }
        }
Example #9
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var s = await _service.AddAsync(PersonToAdd);

            if (s != OperationStatus.OK)
            {
                return(HandleError(s, _action));
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> SingUp(int IdentityDocumentTypeId, string IdentityDocumentTypeNumber, string FatherLastName, string MotherLastName, string Name, string Email, string Password)
        {
            PersonEntity personEntity = new PersonEntity();
            UserEntity   userEntity   = new UserEntity();

            personEntity.PersonId = 0;
            personEntity.IdentityDocumentTypeId = IdentityDocumentTypeId;
            personEntity.IdentityDocumentNumber = IdentityDocumentTypeNumber;
            personEntity.FatherLastName         = FatherLastName;
            personEntity.MotherLastName         = MotherLastName;
            personEntity.Name        = Name;
            personEntity.Email       = Email;
            personEntity.CreatorUser = "";
            personEntity.UpdaterUser = "";
            personEntity.CreateDate  = DateTime.Now;
            personEntity.UpdateDate  = DateTime.Now;
            personEntity.Status      = true;
            personEntity.Removed     = false;

            var indicadorPerson = await _personService.AddAsync(personEntity);

            userEntity.UserId      = 0;
            userEntity.PersonId    = personEntity.PersonId;
            userEntity.UserName    = personEntity.IdentityDocumentNumber;
            userEntity.Password    = UtilitarianUTL.EncriptarCadena(Password);
            userEntity.CreatorUser = "";
            userEntity.UpdaterUser = "";
            userEntity.CreateDate  = DateTime.Now;
            userEntity.UpdateDate  = DateTime.Now;
            userEntity.Status      = true;
            userEntity.Removed     = false;

            var indicadorUser = await _userService.AddAsync(userEntity);

            if (indicadorUser == 1)
            {
                return(RedirectToAction("Index", "Login"));
            }


            return(View());
        }
Example #11
0
        public async Task <IActionResult> Create([FromBody] PersonCommand command)
        {
            if (command is null)
            {
                return(BadRequest());
            }

            Person person = await _personService.AddAsync(command);

            if (person is null)
            {
                return(BadRequest(_personService.ValidationResult()
                                  .Errors
                                  .Select(x => new ValidationResult()
                {
                    PropertyName = x.PropertyName, ErrorMessage = x.ErrorMessage
                })));
            }

            return(Ok(_mapper.Map <Person, PersonResult>(person)));
        }
Example #12
0
        public async Task <IActionResult> AddPerson([FromBody] CreatePersonModel user)
        {
            var userEntity = _mapper.Map <PersonEntity>(user);

            var res = await _persons.GetByUsername(user.Username).ConfigureAwait(false);

            if (res != null)
            {
                return(BadRequest());
            }

            var ress = await _persons.GetByEmail(user.Email).ConfigureAwait(false);

            if (ress != null)
            {
                return(BadRequest());
            }
            userEntity.Password = PersonExtensions.PasswordHashing(userEntity.Password);
            await _persons.AddAsync(userEntity).ConfigureAwait(false);

            var userResult = await _persons.GetByIdAsync(userEntity.Id).ConfigureAwait(false);

            return(CreatedAtRoute("GetPersonById", new { id = userResult.Id }, _mapper.Map <PersonEntity>(userResult)));
        }
Example #13
0
 public async Task <OperationResult <IKeyedDto> > PostAsync([FromBody] BasePersonDto model)
 {
     return(await _service.AddAsync(model));
 }
Example #14
0
        public async Task <PersonViewModel> Add(PersonViewModel person)
        {
            PersonDTO _person = await personService.AddAsync(mapper.Map <PersonDTO>(person));

            return(mapper.Map <PersonViewModel>(_person));
        }
Example #15
0
 public async Task <IActionResult> PostPerson(Person person) => await _personService.AddAsync(person);
Example #16
0
        public async Task <IActionResult> Save(PersonDto personDto)
        {
            var newPerson = await _personService.AddAsync(_mapper.Map <Person>(personDto));

            return(Created("", _mapper.Map <PersonDto>(newPerson)));
        }
        public async Task <ObjectResult> AddAsync([FromBody] PersonModel model)
        {
            var result = await _personService.AddAsync(model);

            return(BaseResult(result));
        }
Example #18
0
        public async Task <IActionResult> Create(PersonDto personDto)
        {
            await _personService.AddAsync(_mapper.Map <Person>(personDto));

            return(RedirectToAction("Index"));
        }
Example #19
0
        public async Task <ActionResult <Person> > Post(Person person)
        {
            await _personService.AddAsync(person).ConfigureAwait(false);

            return(CreatedAtAction("Get", new { id = person.PersonId }, person));
        }