Beispiel #1
0
        public ResponseViewModel postchargingHistory(ChargingHistoryModel chargingHistory)
        {
            var data = new ResponseViewModel();

            chargingHistory.Id = MongoDB.Bson.ObjectId.GenerateNewId().ToString();
            ChargingHistoryModel re = eVChargingDBContext.charginghistory.Find(y => y.UserId == chargingHistory.UserId && y.StationId == chargingHistory.StationId).FirstOrDefault();

            if (re == null)
            {
                Users res = eVChargingDBContext.users.Find(r => r.Id == chargingHistory.UserId).FirstOrDefault();
                if (res == null)
                {
                    return(null);
                }
                eVChargingDBContext.charginghistory.InsertOne(chargingHistory);

                data.StatusCode = "200";
                data.Messages   = "data saved Successfully";
                return(data);
            }
            else
            {
                data.StatusCode = "208";
                data.Messages   = "Station Already Stored...";
                return(data);
            }
        }
Beispiel #2
0
 public ActionResult PostChargingHistory([FromBody] ChargingHistoryModel chargingHistory)
 {
     try
     {
         var res = userServices.postchargingHistory(chargingHistory);
         if (res == null)
         {
             return(NotFound());
         }
         if (res.StatusCode == "208")
         {
             return(NotFound(res));
         }
         return(Ok(res));
     }
     catch (Exception ex)
     {
         logHelper.ErrorLogs("UsersController", "PostChargingHistory", "", ex);
         return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }