public ActionResult New(SeriesAddViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (DB_TESTASPNETEntities db = new DB_TESTASPNETEntities())
                    {
                        if (!existUser(model.UserName.Trim()))
                        {
                            createUser(model.UserName.Trim());
                        }
                        var oTabla = new Series();
                        oTabla.IDUser       = getUserId(model.UserName);
                        oTabla.SeriesSplit  = calculatedSerie(model.InvtervalInitial, model.InvtervalEnd);
                        oTabla.CreationDate = DateTime.Now;
                        db.Series.Add(oTabla);
                        db.SaveChanges();
                    }
                    return(Redirect("~/Series/"));
                }

                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private int createUser(string userName)
        {
            int idUser = -1;

            using (DB_TESTASPNETEntities db = new DB_TESTASPNETEntities())
            {
                var oTabla = new Users();
                oTabla.UserName     = userName;
                oTabla.CreationDate = DateTime.Now;
                db.Users.Add(oTabla);
                db.SaveChanges();
                idUser = oTabla.IDUser;
            }
            return(idUser);
        }