Insert() public method

Adds a record to the database. You can pass in an Anonymous object, an ExpandoObject, A regular old POCO, or a NameValueColletion from a Request.Form or Request.QueryString
public Insert ( object o ) : dynamic
o object
return dynamic
Example #1
0
        public static void InsertInto(this object o, string table, ConnectionProfile connectionProfile = null)
        {
            if (connectionProfile == null) connectionProfile = new ConnectionProfile();

            DynamicModel dynamicModel = new DynamicModel(connectionProfile, table, "Id");

            dynamicModel.Insert(o);
        }
Example #2
0
        private NyResult Register(string email, string password, string reason)
        {
            var result = this.users.Register(email, password, password);

            if (result.Success)
            {
                // Add approval request and send a notification email
                try
                {
                    var db = new DynamicModel("NietoYostenDb", "ApprovalRequests");
                    db.Insert(new { UserID = result.User.ID, Reason = reason });
                    this.SendNewUserRegistrationNotificationToAdmins(email, reason);
                }
                catch (Exception ex)
                {
                    ErrorSignal.FromCurrentContext().Raise(ex);
                    return new NyResult
                    {
                        Success = false,
                        Message = "Ocurrió un error al solicitar la aprovación del usuario."
                    };
                }

                return new NyResult
                {
                    Success = true,
                    Message = result.Message
                };
            }

            return new NyResult
            {
                Success = false,
                Message = result.Message
            };
        }
Example #3
0
 public void SaveTable(DynamicModel table, List<dynamic> items )
 {
     foreach (dynamic item in items)
     {
         if (item.State == RowState.New)
         {
             table.Insert(item);
         }
         else if(item.State == RowState.Updated)
         {
             table.Update(item, item.ID);
         }
     }
 }
Example #4
0
        public ActionResult Register(string email, string password, string confirm, string reason)
        {
            var result = this.users.Register(email, password, confirm);

            if (result.Success)
            {
                // Add approval request and send a notification email
                try
                {
                    var db = new DynamicModel("NietoYostenDb", "ApprovalRequests");
                    db.Insert(new {UserID = result.User.ID, Reason = reason});

                    SendNewUserRegistrationNotificationToAdmins(email, reason);
                }
                catch (Exception ex)
                {
                    ErrorSignal.FromCurrentContext().Raise(ex);

                    this.SetAlertMessage("Ocurrió un error al solicitar la aprovación del usuario.", AlertClass.AlertDanger);
                    return View();
                }

                NyUtil.SetAlertMessage(this, result.Message, AlertClass.AlertSuccess);
                return RedirectToAction("Index", "Home");
            }

            NyUtil.SetAlertMessage(this, result.Message, AlertClass.AlertDanger);
            return View();
        }