コード例 #1
0
        public async Task <IActionResult> PostMThrmsresourceRequisition([FromRoute] long idd, [FromBody] MThrmsresourceRequisition mThrmsresourceRequisition)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.MThrmsresourceRequisition.Add(mThrmsresourceRequisition);
            await _context.SaveChangesAsync();

            for (int i = 1; i <= idd; i++)
            {
                long id = mThrmsresourceRequisition.MThrmsresourceRequisitionId;
                MThrmsresourceAllocation aa = new MThrmsresourceAllocation();
                aa.DesignationId = mThrmsresourceRequisition.DesignationId;
                aa.MThrmsresourceAllocationId = 0;
                aa.ResourceRequisitionId      = id;
                aa.ManPowerId = mThrmsresourceRequisition.ManPowerId;
                _context.MThrmsresourceAllocation.Add(aa);
                await _context.SaveChangesAsync();
            }



            return(CreatedAtAction("GetMThrmsresourceRequisition", new { id = mThrmsresourceRequisition.MThrmsresourceRequisitionId }, mThrmsresourceRequisition));
        }
コード例 #2
0
        public async Task <IActionResult> PostMThrmsresourceAllocation([FromBody] MThrmsresourceAllocation mThrmsresourceAllocation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.MThrmsresourceAllocation.Add(mThrmsresourceAllocation);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMThrmsresourceAllocation", new { id = mThrmsresourceAllocation.MThrmsresourceAllocationId }, mThrmsresourceAllocation));
        }
コード例 #3
0
        public async Task <IActionResult> PutMThrmsresourceAllocation2([FromRoute] long id, [FromRoute] long recr)
        {
            // if (!ModelState.IsValid)
            // {
            //     return BadRequest(ModelState);
            // }

            // if (id != mThrmsresourceAllocation.MThrmsresourceAllocationId)
            // {
            //     return BadRequest();
            // }

            // _context.Entry(mThrmsresourceAllocation).State = EntityState.Modified;

            // try
            // {
            //     await _context.SaveChangesAsync();
            // }
            // catch (DbUpdateConcurrencyException)
            // {
            //     if (!MThrmsresourceAllocationExists(id))
            //     {
            //         return NotFound();
            //     }
            //     else
            //     {
            //         throw;
            //     }
            // }
            // return CreatedAtAction("GetMThrmsresourceAllocation", mThrmsresourceAllocation.MThrmsresourceAllocationId, mThrmsresourceAllocation);
            AMTDEVContext _context = new AMTDEVContext();
            var           user     = new MThrmsresourceAllocation {
                MThrmsresourceAllocationId = id, RecruiterId = recr
            };

            _context.MThrmsresourceAllocation.Attach(user).Property(x => x.RecruiterId).IsModified = true;
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMThrmsresourceAllocation", user.MThrmsresourceAllocationId, user));
        }
コード例 #4
0
        public async Task <IActionResult> PutMThrmsresourceAllocation([FromRoute] long id, [FromBody] MThrmsresourceAllocation mThrmsresourceAllocation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != mThrmsresourceAllocation.MThrmsresourceAllocationId)
            {
                return(BadRequest());
            }

            _context.Entry(mThrmsresourceAllocation).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MThrmsresourceAllocationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(CreatedAtAction("GetMThrmsresourceAllocation", mThrmsresourceAllocation.MThrmsresourceAllocationId, mThrmsresourceAllocation));
            //return NoContent();
        }