public APIResult UpdateActivityLog(TblActivityLog data)
        {
            APIResult res = new APIResult();
            using (Sonartez_server db = new Sonartez_server(connectionString))
            {
                var matchedObj = (from c in db.TblActivityLog
                                  where c.ID == data.ID
                                  select c).SingleOrDefault();

                if (matchedObj == null)
                {
                    try
                    {
                        // does not exist
                        Table<TblActivityLog> TblObj = db.TblActivityLog;
                        data.ServerUpdate = DateTime.Now;
                        TblObj.InsertOnSubmit(data);
                        TblObj.Context.SubmitChanges();

                        res.UpdateDate = data.ServerUpdate.Value;
                        res.Success = true;

                    }
                    catch (Exception ex)
                    {
                        res.Message = ex.Message;
                        res.Success = false;
                    }
                }
                else
                {
                    try
                    {
                        matchedObj.ActivityType = data.ActivityType;
                        matchedObj.ClientName = data.ClientName;
                        matchedObj.Descriptions = data.Descriptions;
                        matchedObj.ClientID = data.ClientID;
                        matchedObj.UserID = data.UserID;
                        matchedObj.UserName = data.UserName;
                        matchedObj.ServerUpdate = DateTime.Now;
                        matchedObj.CreateDate = data.CreateDate;
                        db.SubmitChanges();

                        res.UpdateDate = data.ServerUpdate.Value;
                        res.Success = true;
                    }
                    catch (Exception ex)
                    {
                        res.Message = ex.Message;
                        res.Success = false;
                    }
                }

            }
            return res;
        }
Exemple #2
0
 partial void UpdateTblActivityLog(TblActivityLog instance);
Exemple #3
0
 partial void DeleteTblActivityLog(TblActivityLog instance);
Exemple #4
0
 partial void InsertTblActivityLog(TblActivityLog instance);