Ejemplo n.º 1
0
        public ApiResult Save()
        {
            var apiResult = new ApiResult()
            {
                StatusCode = StatusCode.Success
            };
            var now = DateTime.UtcNow;
            var dc  = new PredictionExamplesDataContext(SqlConnectionString);

            if (this.Id == 0)
            {
                var r = new PredictionEntity();
                r.SynAppsDeviceId = this.SynAppsDeviceId;
                r.LuisExampleId   = this.LuisExampleId;
                r.EntityName      = this.EntityName;
                r.EntityValue     = this.EntityValue;
                r.CreatedAt       = now;
                r.UpdatedAt       = now;

                try
                {
                    dc.PredictionEntities.InsertOnSubmit(r);
                    dc.SubmitChanges();

                    this.Id        = r.Id;
                    this.CreatedAt = r.CreatedAt;
                    this.UpdatedAt = r.UpdatedAt;
                }
                catch (Exception e)
                {
                    apiResult.StatusCode = StatusCode.Error;
                    apiResult.Message    = e.Message;
                }
            }
            else
            {
                var records =
                    from n in dc.PredictionEntities
                    where n.Id == this.Id
                    select n;

                foreach (var r in records)
                {
                    r.SynAppsDeviceId = this.SynAppsDeviceId;
                    r.LuisExampleId   = this.LuisExampleId;
                    r.EntityName      = this.EntityName;
                    r.EntityValue     = this.EntityValue;
                    r.UpdatedAt       = now;
                }

                try
                {
                    dc.SubmitChanges();
                }
                catch (Exception e)
                {
                    apiResult.StatusCode = StatusCode.Error;
                    apiResult.Message    = e.Message;
                }
            }

            return(apiResult);
        }
Ejemplo n.º 2
0
 partial void UpdatePredictionEntity(PredictionEntity instance);
Ejemplo n.º 3
0
 partial void DeletePredictionEntity(PredictionEntity instance);
Ejemplo n.º 4
0
 partial void InsertPredictionEntity(PredictionEntity instance);