Exemple #1
0
        public async Task Update(EdcHeartBeat data)
        {
            if (data != null)
            {
                try {
                    string   now        = DateTime.Now.ToString("s") + "Z";
                    DateTime tanggalNow = DateTime.Parse(now);

                    var dataToUpdate = new EdcHeartBeat();
                    dataToUpdate.site_id         = data.site_id;
                    dataToUpdate.app_datetime    = data.app_datetime;
                    dataToUpdate.server_datetime = tanggalNow;
                    Logger.Info("Heart Beat - data to update = " + dataToUpdate);

                    await _context.server_status.SingleOrDefaultAsync(r => r.site_id == data.site_id);

                    await _context.SaveChangesAsync();

                    Logger.Info("Heart Beat update successfully");
                } catch (Exception ex) {
                    Debug.WriteLine("Update Data Exception: " + ex.Message);
                    throw;
                }
            }
        }
Exemple #2
0
        public async Task Insert(EdcHeartBeat data)
        {
            if (data != null)
            {
                try {
                    string   now        = DateTime.Now.ToString("s") + "Z";
                    DateTime tanggalNow = DateTime.Parse(now);

                    var dataToInsert = new EdcHeartBeat();
                    dataToInsert.site_id         = data.site_id;
                    dataToInsert.app_datetime    = data.app_datetime;
                    dataToInsert.server_datetime = tanggalNow;
                    Logger.Info("Heart Beat - data to insert = " + dataToInsert);

                    await _context.server_status.AddAsync(dataToInsert);

                    await _context.SaveChangesAsync();

                    Logger.Info("Heart Beat insert successfully");
                } catch (Exception ex) {
                    Debug.WriteLine("Insert Data Exception: " + ex.Message);
                    throw;
                }
            }
        }
Exemple #3
0
        public async Task <IActionResult> Update([FromBody] EdcHeartBeat data)
        {
            Logger.Info("Heart Beat - Data Payload = " + data);
            if (data == null)
            {
                return(StatusCode(500, Json(new { message = "INTERNAL SERVER ERROR: Data isn't match or one of data is null" })));
            }
            await EdcHeartBeatRepo.Update(data);

            return(StatusCode(201, Json(new { message = "Update data is successfully" })));
        }