Ejemplo n.º 1
0
        public async Task CreateAward(CreateAwardDto input)
        {
            var header = _employeeRepository.Get(input.EmployeeId);

            var @employeeaward = input.MapTo <Award>();

            @employeeaward.TenantId = AbpSession.GetTenantId();

            @employeeaward = Award.Create(input.AwardName, input.AwardDate.Value, input.Remark);

            header.Awards.Add(@employeeaward);

            await CurrentUnitOfWork.SaveChangesAsync();
        }
        public async Task<IHttpActionResult> Post(Award model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            try
            {
                model.Create(db);

                db.Awards.Add(model);

                await db.SaveChangesAsync();

                return Ok(model);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("PostError", ex.Message);

                return BadRequest(ModelState);
            }
        }