public IActionResult Delete(int id, [FromBody] Checkchart item)
        {
            if (item == null || item.Id != id)
            {
                return(BadRequest());
            }

            Checkchart found = _items.Find(i => i.Id == id);

            if (found == null)
            {
                return(NotFound());
            }

            if (found.Sendtodatetime != null)
            {
                found.Sendtouser     = null;
                found.Sendtobyuser   = null;
                found.Sendtoposition = null;
                found.Sendtodatetime = null;
            }
            else
            {
                found.Cxlbyuser         = item.Cxlbyuser;
                found.Cxlbyuserdatetime = DateTime.Now;
                found.Cxlbyuserreason   = item.Cxlbyuserreason;
            }

            _items.Commit();

            _hubContext.Clients.All.AnDeleted(item);

            return(new NoContentResult());
        }
        public IActionResult UpdateMultiple([FromBody] List <Checkchart> item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            foreach (var i in item)
            {
                Checkchart found = _items.Find(f => f.Id == i.Id);

                if (found == null)
                {
                    return(NotFound());
                }

                found.Sendtouser     = i.Sendtouser;
                found.Sendtoposition = i.Sendtoposition;
                found.Sendtodatetime = DateTime.Now;
                found.Sendtobyuser   = i.Sendtobyuser;

                _items.Commit();
            }

            _hubContext.Clients.All.AnUpdated(item);

            return(new NoContentResult());
        }
        public IActionResult Create([FromBody] Checkchart item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            int isAlreadyItem = _items.GetAll().Count(c => c.An == item.An && c.Receivebyposition == item.Receivebyposition && c.Cxlbyuserdatetime == null);

            if (isAlreadyItem == 0)
            {
                item.Receivebydatetime = DateTime.Now;
                _items.Add(item);
                _items.Commit();
            }
            CreatedAtRouteResult result = CreatedAtRoute("GetCheckchart", new { controller = "Checkchart", an = item.An }, item);

            return(result);
        }
        public IActionResult Update(int id, [FromBody] Checkchart item)
        {
            if (item == null || item.Id != id)
            {
                return(BadRequest());
            }

            Checkchart found = _items.Find(i => i.Id == id);

            if (found == null)
            {
                return(NotFound());
            }

            found.Sendtouser     = item.Sendtouser;
            found.Sendtoposition = item.Sendtoposition;
            found.Sendtodatetime = DateTime.Now;
            found.Sendtobyuser   = item.Sendtobyuser;


            _items.Commit();

            return(new NoContentResult());
        }