public Task <EmpPhoneModel> GetAsync(int id)
        {
            var dal = _empPhoneRepository.Get(id);

            if (dal == null)
            {
                return(Task.FromResult <EmpPhoneModel>(null));
            }
            else
            {
                EmpPhoneModel model = AutoMapperGenericHelper <EmpPhone, EmpPhoneModel> .Convert(dal);

                return(Task.FromResult(model));
            }
        }
示例#2
0
        public IHttpActionResult Put(EmpPhoneModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                _empPhoneService.UpdateAsync(model);
                return(Ok());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        public Task UpdateAsync(EmpPhoneModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("EmpPhoneModel ArgumentNullException Insert Async");
            }

            EmpPhone dto = AutoMapperGenericHelper <EmpPhoneModel, EmpPhone> .Convert(model);

            EmpEmployeePk pk1 = _empEmployeePkRepository.Get((int)model.EmployeePkId);

            dto.EmpEmployeePk = pk1;
            if (pk1 == null)
            {
                throw new ArgumentNullException("EmployeePkId ArgumentNullException Insert Async");
            }


            _empPhoneRepository.Update(dto);

            return(Task.FromResult <object>(null));
        }