Exemple #1
0
        public IActionResult Post(RequestDriver request)
        {
            var Drivers = request.data.attributes;
            var date    = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()).TotalSeconds;

            Drivers.created_at = (long)date;
            Drivers.updated_at = (long)date;
            _context.Drivers.Add(Drivers);
            _context.SaveChanges();
            return(Ok(new { message = "success add data", status = true, data = Drivers }));
        }
Exemple #2
0
        public IActionResult PutById(int id, RequestDriver request)
        {
            var products = request.data.attributes;

            try
            {
                var result = _context.Drivers.First(x => x.id == id);
                result.full_name  = products.full_name;
                result.updated_at = (long)(DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()).TotalSeconds;
                _context.SaveChanges();
                return(Ok(new { message = "success update data", status = true, data = result }));
            }
            catch (Exception)
            {
                return(NotFound());
            }
        }