Ejemplo n.º 1
0
        public IHttpActionResult UpdateDeviceToken(DeviceTokenVM model)
        {
            StringBuilder traceLog = null;
            // string token = string.Empty;
            ServiceResponse <bool> totalNotifaication = null;

            try
            {
                traceLog = new StringBuilder();
                traceLog.AppendLine("Start: UpdateDeviceToken Request Data:-DeviceToken-" + model.DeviceToken + ",DeviceType-" + model.DeviceType + ",AuthToken-" + model.AuthToken);
                bool isUpdated = CommonWebApiBL.UpdateDeviceTokenAndType(model);
                totalNotifaication              = new ServiceResponse <bool>();
                totalNotifaication.jsonData     = isUpdated;
                totalNotifaication.IsResultTrue = true;
                return(Ok(totalNotifaication));
            }
            catch (Exception ex)
            {
                LogManager.LogManagerInstance.WriteErrorLog(ex);
                totalNotifaication.IsResultTrue = false;
                totalNotifaication.ErrorMessage = Message.ServerError;
                return(Ok(totalNotifaication));
            }
            finally
            {
                traceLog.AppendLine("End: UpdateDeviceToken() Response Result Status-" + totalNotifaication.IsResultTrue + ",Modified DatetTime" + DateTime.Now.ToLongDateString());
                LogManager.LogManagerInstance.WriteTraceLog(traceLog);
                traceLog = null;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Update Device Token And Type based on AuthToken
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool UpdateDeviceTokenAndType(DeviceTokenVM model)
 {
     using (LinksMediaContext _dbContext = new LinksMediaContext())
     {
         StringBuilder traceLog = null;
         try
         {
             traceLog = new StringBuilder();
             traceLog.AppendLine("Start: UpdateDeviceTokenAndType()");
             if (!string.IsNullOrEmpty(model.AuthToken))
             {
                 var userToken = _dbContext.UserToken.Where(dn => dn.Token.Equals(model.AuthToken.Trim())).FirstOrDefault();
                 if (userToken != null)
                 {
                     userToken.TokenDevicesID = model.DeviceToken;
                     userToken.DeviceType     = model.DeviceType.ToString();
                     _dbContext.SaveChanges();
                     return(true);
                 }
             }
             return(false);
         }
         finally
         {
             traceLog.AppendLine("End: UpdateDeviceTokenAndType --- " + DateTime.Now.ToLongDateString());
             LogManager.LogManagerInstance.WriteTraceLog(traceLog);
         }
     }
 }