Esempio n. 1
0
        public async Task <IHttpActionResult> PostIdentity([FromBody] string contacts)
        {
            DataClassesManager.ControllerLog("info", _User.Id, this.Request.RequestUri.PathAndQuery, string.Format("{0}#{1}:{2}", "", _User.Username, string.IsNullOrEmpty(contacts) ? "NULL" : (contacts.Length > 20 ? contacts.Substring(0, 20) + "..." : contacts)));

            DateTimeOffset?ack; string countryCode;

            DataClassesManager.GetUserSyncInfo(_User.UserId.Value, out countryCode, out ack);
            string error  = string.Empty;
            var    script = Helper.SynchronizeUtils.GenerateSynchronizeIdentityTSQL(_User.UserId.Value, countryCode, contacts, out error);

            if (!string.IsNullOrEmpty(error))
            {
                DataClassesManager.ControllerLog("error", _User.Id, this.Request.RequestUri.PathAndQuery, string.Format("{0}#{1}:{2}", "", _User.Username, error));
                return(BadRequest(error));
            }

            DataClassesManager.ExecuteSynchronizeScript(_User.UserId.Value, script, "Identity", ack, out error);
            if (string.IsNullOrEmpty(error))
            {
                DataClassesManager.ControllerLog("info", _User.Id, this.Request.RequestUri.PathAndQuery, string.Format("{0}#{1}:{2}:{3}", "", _User.Username, ack, "Done"));
            }
            else
            {
                DataClassesManager.ControllerLog("error", _User.Id, this.Request.RequestUri.PathAndQuery, string.Format("{0}#{1}:{2}", "", _User.Username, error));
            }


            DataClassesManager.ControllerLog("info", _User.Id, this.Request.RequestUri.PathAndQuery, string.Format("{0}#{1}:{2}", "", _User.Username, ack));
            return(Ok(new { ack = ack }));
        }