Beispiel #1
0
        public Task <EmpAdressModel> GetAsync(int id)
        {
            var dal = _empAdressRepository.Get(id);

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

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

                _empAdressService.UpdateAsync(model);
                return(Ok());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Beispiel #3
0
        public Task UpdateAsync(EmpAdressModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("EmpAdressModel ArgumentNullException Insert Async");
            }

            EmpAdress dto = AutoMapperGenericHelper <EmpAdressModel, EmpAdress> .Convert(model);

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

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


            _empAdressRepository.Update(dto);

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