コード例 #1
0
        public IActionResult Put(int id, [FromBody] UpdateConsultantViewModel vm)
        {
            return(ApiAction(() =>
            {
                var contract = _mapper.Map <UpdateConsultantContract>(vm);
                contract.Id = id;
                _consultantService.Update(contract);

                return Accepted(new { id });
            }));
        }
コード例 #2
0
 public IActionResult Update(Consultant consultant)
 {
     consultantService.Update(consultant);
     return(NoContent());
 }
コード例 #3
0
        public IActionResult Put(ConslutantDto cDTO)
        {
            EmployeeDto emp = new EmployeeDto();
            AccountDto  acc = new AccountDto();

            IList <Contract> contract = new List <Contract>();

            foreach (var contr in cDTO.Contracts)
            {
                var contracttype = new ContractType()
                {
                    Title = contr.ContractTypeTitle,
                    Id    = contr.ContractTypeId
                };
                contract.Add(new Contract
                {
                    EndDate        = contr.EndDate,
                    StartDate      = contr.StartDate,
                    DocumentUrl    = contr.DocumentUrl,
                    Salary         = contr.Salary,
                    SignedDate     = contr.SignedDate,
                    Commentary     = contr.Commentary,
                    PurchasePrice  = contr.PurchasePrice,
                    SellingPrice   = contr.SellingPrice,
                    Id             = contr.Id,
                    ConsultantId   = cDTO.Id,
                    ContractTypeId = contracttype.Id,
                    ContractType   = contracttype
                });
            }

            var address = new Address()
            {
                City    = cDTO.City,
                Number  = cDTO.Number,
                Street  = cDTO.Street,
                Zip     = cDTO.Zip,
                Country = cDTO.Country,
                Id      = cDTO.AddressId
            };


            if (cDTO.Account != null)
            {
                var account = new AccountDto()
                {
                    CompanyName = cDTO.Account.CompanyName,
                    VatNumber   = cDTO.Account.VatNumber,
                    Id          = cDTO.AccountId
                };
                acc = account;
            }
            else if (cDTO.AccountId != Guid.Empty)
            {
                var account = new AccountDto()
                {
                    Id = cDTO.AccountId
                };
                acc = account;
            }
            else
            {
                acc = null;
            }


            if (cDTO.Employee != null)
            {
                var employee = new EmployeeDto()
                {
                    Firstname = cDTO.Employee.Firstname,
                    Email     = cDTO.Employee.Email,
                    Telephone = cDTO.Employee.Telephone,
                    Lastname  = cDTO.Employee.Lastname,
                    Id        = cDTO.EmployeeId
                };
                emp = employee;
            }
            else if (cDTO.EmployeeId != Guid.Empty)
            {
                var employee = new EmployeeDto()
                {
                    Id = cDTO.EmployeeId,
                };

                emp = employee;
            }
            else
            {
                emp = null;
            }

            var consultant = new Consultant()
            {
                Id        = cDTO.Id,
                Firstname = cDTO.Firstname,
                Lastname  = cDTO.Lastname,
                Birthdate = cDTO.Birthdate,
                Email     = cDTO.Email,
                WorkEmail = cDTO.WorkEmail,
                Mobile    = cDTO.Mobile,
                Telephone = cDTO.Telephone,

                Address   = address,
                AddressId = address.Id,

                EmployeeId = emp?.Id,

                AccountId = acc?.Id,

                Contracts = contract
            };



            Guid id = consultant.Id;

            service.Update(consultant);
            return(Ok(cDTO));
        }