Exemple #1
0
        public async Task <ActionResult <ColorClockFace> > Update([FromBody] ColorClockFace body, [FromRoute] int Id = 0)
        {
            if (!ModelState.IsValid || Id < 1)
            {
                return(BadRequest(ModelState));
            }

            var GetItem = await _UnitOfWork.ColorClockFaces.GetById(Id);

            ResultData <ColorClockFace> data = new ResultData <ColorClockFace>();

            if (GetItem == null)
            {
                return(Ok(data));
            }
            #region
            GetItem.Name = body.Name;
            #endregion
            await _UnitOfWork.ColorClockFaces.Update(GetItem, true);

            data.Data    = body;
            data.Success = true;
            data.Message = "Thành công !";
            return(Ok(GetItem));
        }
Exemple #2
0
        public async Task <ActionResult <ResultData <ColorClockFace> > > GetById([FromRoute] int Id)
        {
            ResultData <ColorClockFace> data = new ResultData <ColorClockFace>();
            ColorClockFace Item = await _UnitOfWork.ColorClockFaces.GetById(Id);

            if (data == null)
            {
                return(data);
            }
            data.Data    = Item;
            data.Success = true;
            data.Message = "Thành công !";
            return(Ok(data));
        }
Exemple #3
0
        public async Task <ActionResult <ColorClockFace> > Add([FromBody] ColorClockFace body)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            ResultData <ColorClockFace> data = new ResultData <ColorClockFace>();
            await _UnitOfWork.ColorClockFaces.Insert(body);

            await _UnitOfWork.Commit();

            data.Data    = body;
            data.Success = body.Id > 0 ? true : false;
            data.Message = body.Id > 0 ? "Thành công !" : "Thất bại !";
            return(Ok(data));
        }
Exemple #4
0
        public async Task <ActionResult <ActionResult <ColorClockFace> > > Delete([FromRoute] int Id = 0)
        {
            if (Id < 1)
            {
                return(BadRequest(ModelState));
            }
            ResultData <ColorClockFace> data = new ResultData <ColorClockFace>();
            ColorClockFace GetItem           = await _UnitOfWork.ColorClockFaces.GetById(Id);

            if (GetItem == null)
            {
                return(Ok(data));
            }

            GetItem.Status = 1;//delete
            await _UnitOfWork.ColorClockFaces.Delete(GetItem, true);

            data.Data    = GetItem;
            data.Success = true;
            data.Message = "Thành công !";

            return(Ok(data));
        }