Example #1
0
        public async Task <IActionResult> AddOneAsync([FromBody] EquipmentActivity entity)
        {
            if (entity == null)
            {
                return(BadRequest());
            }

            var result = await _entityRepository.AddOneAsync(entity);

            //return CreatedAtRoute("GetEquipmentActivity", new { controller = "EquipmentActivity", id = entity.Id }, entity);
            return(Ok());
        }
        public async Task <ApiResponse <EquipmentActivity> > Post(EquipmentActivity post)
        {
            var resp = new ApiResponse <EquipmentActivity>();

            try
            {
                var equipment = await _context.EquipmentActivityList.AddAsync(post);

                resp.status_code = (int)HttpStatusCode.Created;
                resp.d           = post;
            }
            catch (Exception ex)
            {
                resp.status_code = (int)HttpStatusCode.InternalServerError;
                resp.message     = ex.Message;
            }
            return(resp);
        }
        public async Task <ApiResponse <EquipmentActivity> > Put(int id, EquipmentActivity post)
        {
            var resp = new ApiResponse <EquipmentActivity>();

            try
            {
                var equipment = await _context.EquipmentActivityList.SingleOrDefaultAsync(e => e.ID == id);

                if (equipment != null)
                {
                    _context.EquipmentActivityList.Update(equipment);
                }

                resp.d = equipment;
            }
            catch (Exception ex)
            {
                resp.status_code = (int)HttpStatusCode.InternalServerError;
                resp.message     = ex.Message;
            }
            return(resp);
        }
Example #4
0
 public async Task <ReplaceOneResult> Put([FromBody] EquipmentActivity entity)
 // public async Task<bool> Put([FromBody]EquipmentActivity entity)
 {
     return(await _entityRepository.SaveOneAsync(entity));
 }