Example #1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            MyDataModel context = new MyDataModel();

            string email    = tbxEmail.Text;
            string password = tbxPassword.Text;

            T_ACCOUNT existingAccount = T_ACCOUNTservice.GetAccountByEmail(context, email);

            if (existingAccount == null)
            {
                lblError.Text = string.Format("Email '{0}' isn't registered.", email);
            }
            else if (existingAccount.Active == false)
            {
                lblError.Text = string.Format("Email '{0}' is blocked.", email);
            }
            else if (existingAccount.Password != password)
            {
                lblError.Text = "Invalid password.";
            }
            else
            {
                FormsAuthentication.SetAuthCookie(email, false);
                FormsAuthentication.RedirectFromLoginPage(email, false);
            }
        }
        public Result OnStartup(UIControlledApplication application)
        {
            RibbonPanel panel = application.CreateRibbonPanel("exercise");

            string         thisAssemblyPath = Assembly.GetExecutingAssembly().Location;
            PushButtonData bData            = new PushButtonData("SendObject",
                                                                 "SendObject", thisAssemblyPath, "App_Framework.Sender");

            PushButton button = panel.AddItem(bData) as PushButton;

            button.ToolTip = "Send Object";


            _serverPipe = new ServerPipe("Test", p => p.StartByteReaderAsync());

            _testObject = new MyDataModel
            {
                test = 1
            };

            ExternalEventHandler handler = new ExternalEventHandler();
            ExternalEvent        exEvent = ExternalEvent.Create(handler);

            handler.ev = exEvent;

            _serverPipe.DataReceived += (s, e) => handler.DataReceived(e);



            return(Result.Succeeded);
        }
Example #3
0
        protected void chkDone_CheckedChanged(object sender, EventArgs e)
        {
            MyDataModel context  = new MyDataModel();
            CheckBox    checkbox = (CheckBox)sender;
            GridViewRow row      = (GridViewRow)((checkbox).NamingContainer);
            int         goalID   = int.Parse(((Label)row.FindControl("HiddenGoalID")).Text.Trim());

            if (checkbox.Checked)
            {
                T_GOALservice.GetGoalByID(context, goalID).Done = true;
                foreach (var task in T_TASKservice.GetTasksByGoalID(context, goalID))
                {
                    task.Done = true;
                }
            }
            else
            {
                T_GOALservice.GetGoalByID(context, goalID).Done = false;
                foreach (var task in T_TASKservice.GetTasksByGoalID(context, goalID))
                {
                    task.Done = false;
                }
            }
            context.SaveChanges();

            BindData();
        }
        public async Task QueryMixed_main_index()
        {
            // arrange
            var id      = GetRandomString(10);
            var record1 = new MyRecord {
                Id    = id,
                SubId = GetRandomString(10),
                Value = "Hello"
            };
            await Table.PutItemAsync(MyDataModel.GetPrimaryKey(record1), record1);

            var record2 = new MyOtherRecord {
                Id    = id,
                SubId = GetRandomString(10),
                Name  = "Bob"
            };
            await Table.PutItemAsync(MyDataModel.GetPrimaryKey(record2), record2);

            // act
            var result = await Table.Query(MyDataModel.SelectMyRecordsAndMyOtherRecords(record1.Id), consistentRead : true)
                         .ExecuteAsync();

            // assert
            result.Should().HaveCount(2);
            result.Should().ContainEquivalentOf(record1);
            result.Should().ContainEquivalentOf(record2);
        }
Example #5
0
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            MyDataModel context = new MyDataModel();

            tbxEmail.BorderColor = Color.Empty;

            string email    = tbxEmail.Text.Trim();
            string password = tbxPassword.Text.Trim();

            if (T_ACCOUNTservice.GetAccountByEmail(context, email) != null)
            {
                lblConfirmation.Text    = Messages.errorMailExists;
                lblConfirmation.Visible = true;
                tbxEmail.BorderColor    = Color.Red;
            }
            else
            {
                string    name       = tbxFirstName.Text;
                string    surname    = tbxSecondName.Text;
                bool      isMale     = dlstGender.SelectedItem.Text == "Male" ? true : false;
                T_ACCOUNT newAccount = new T_ACCOUNT()
                {
                    Email = email, Password = password, Name = name, Surname = surname, IsMale = isMale, Active = true
                };
                context.T_ACCOUNT.Add(newAccount);
                context.SaveChanges();
                lblConfirmation.Text    = string.Format("email '{0}' registered successfully", email);
                lblConfirmation.Visible = true;
                btnConfirm.Enabled      = false;
            }
        }
Example #6
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            MyDataModel context = new MyDataModel();

            foreach (GridViewRow row in GridView1.Rows)
            {
                CheckBox chkTask = (CheckBox)row.FindControl("chkGoal");

                if (chkTask.Checked)
                {
                    int goalID = int.Parse(((Label)row.FindControl("HiddenGoalID")).Text.Trim());
                    IQueryable <T_TASK> tasksForDelete = T_TASKservice.GetTasksByGoalID(context, goalID);
                    if (tasksForDelete.Any())
                    {
                        foreach (var task in tasksForDelete)
                        {
                            context.T_TASK.Remove(task);
                        }
                    }
                    T_GOAL goalForDelete = T_GOALservice.GetGoalByID(context, goalID);
                    context.T_GOAL.Remove(goalForDelete);
                    context.SaveChanges();
                }
            }

            BindData();
        }
Example #7
0
        public static void RemoveTaskByID(MyDataModel db, int taskID)
        {
            T_TASK taskForDelete = GetTaskByID(db, taskID);

            db.T_TASK.Remove(taskForDelete);
            db.SaveChanges();
        }
Example #8
0
        private static void SetDataToACCAUNT()
        {
            MyDataModel context = new MyDataModel();

            if (!context.T_ACCOUNT.Any())
            {
                List <T_ACCOUNT> states = new List <T_ACCOUNT>()
                {
                    new T_ACCOUNT()
                    {
                        Email = "*****@*****.**", Password = "******", Active = false
                    },
                    new T_ACCOUNT()
                    {
                        Email = "*****@*****.**", Password = "******", Active = true
                    },
                    new T_ACCOUNT()
                    {
                        Email = "*****@*****.**", Password = "******", Active = false
                    },
                };

                context.T_ACCOUNT.AddRange(states);
                context.SaveChanges();
            }
        }
Example #9
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            MyDataModel context  = new MyDataModel();
            string      userName = Page.User.Identity.Name;
            T_ACCOUNT   account  = T_ACCOUNTservice.GetAccountByEmail(context, userName);
            T_GOAL      newGoal  = T_GOALservice.AddNewGoal(context, userName, account);

            Response.Redirect("~/_GoalPage.aspx?GoalID=" + newGoal.GoalID);
        }
Example #10
0
 /// <summary>
 /// Función que permite elimiar una relación al DataModelDocumentWpf.
 /// </summary>
 /// <param name="relation">Relación a ser eliminada.</param>
 public void RemoveRelation(RelationWpf relation)
 {
     if (relation == null)
     {
         throw new ArgumentNullException("relation", "relation can not be null");
     }
     MyDataModel.RemoveRelation(relation);
     this.canvasDraw.Children.Remove(relation.UIElement);
 }
Example #11
0
 /// <summary>
 /// Función que permite agregar una relación al DataModelDocumentWpf.
 /// </summary>
 /// <param name="newRelation">Relación a ser agregada.</param>
 public void AddRelation(RelationWpf newRelation)
 {
     if (newRelation == null)
     {
         throw new ArgumentNullException("newRelation", "newRelation can not be null");
     }
     newRelation.ContextMenuDeleteClick += new RoutedEventHandler(newRelation_ContextMenuDeleteClick);
     MyDataModel.AddRelation(newRelation);
 }
Example #12
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            string fileName = "goal_" + DateTime.Now.ToString("yyyyMMdd") + ".csv";

            Response.Clear();
            Response.Buffer = true;
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName + ";");
            Response.ContentType = "text/csv";
            Response.Charset     = "utf-8";
            StreamWriter sw      = new StreamWriter(Response.OutputStream);
            MyDataModel  context = new MyDataModel();

            int pageIndex = GridView1.PageIndex;

            for (int i = 1; i < GridView1.Columns.Count - 1; i++)
            {
                sw.Write(GridView1.Columns[i] + ",");
            }
            sw.Write(sw.NewLine);

            for (int n = 0; n < GridView1.PageCount; n++)
            {
                GridView1.PageIndex = n;
                BindData();

                foreach (GridViewRow dr in GridView1.Rows)
                {
                    for (int i = 1; i < GridView1.Columns.Count - 1; i++)
                    {
                        string cellValue = dr.Cells[i].Text;
                        cellValue = cellValue.Replace("\r\n", "\\r\\n ");

                        if (i == 1)
                        {
                            Control ctrl = dr.Cells[1].FindControl("chkDone");
                            sw.Write(((CheckBox)ctrl).Text + ',');
                        }
                        else if (i == 2)
                        {
                            Control ctrl     = dr.FindControl("HiddenTaskID");
                            int     taskID   = int.Parse(((Label)ctrl).Text);
                            string  taskName = T_TASKservice.GetTaskByID(context, taskID).TaskName;
                            sw.Write(taskName + ',');
                        }
                        else
                        {
                            sw.Write(cellValue + ',');
                        }
                    }

                    sw.Write(sw.NewLine);
                }
            }
            sw.Close();
            Response.End();
            GridView1.PageIndex = pageIndex;
        }
        public ActionResult Index()
        {
            MyDataModel model = new MyDataModel();
            User        user  = userBusiness.Get.FirstOrDefault(u => u.sID == AuthProvider.UserAntenticated.sID);

            model.login = user.login;
            model.nome  = user.nome;
            return(View(model));
        }
Example #14
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            MyDataModel context = new MyDataModel();
            int         goalID;

            if (!int.TryParse(Request.QueryString["GoalID"], out goalID))
            {
                lblGoalName.Text      = Messages.goalName + Messages.errorMissingGoalID;
                lblGoalName.ForeColor = Color.Red;
                return;
            }

            string taskName = tbxTaskName.Text;

            if (string.IsNullOrEmpty(taskName))
            {
                taskName = "noname";
            }
            string description = tbxDescription.Text;
            bool   isDone      = bool.Parse(dlstDone.SelectedItem.Value);

            T_GOAL goal = T_GOALservice.GetGoalByID(context, goalID);

            if (goal == null)
            {
                lblGoalName.Text      = Messages.goalName + Messages.errorIncorrectGoalID;
                lblGoalName.ForeColor = Color.Red;
                return;
            }

            int taskID;

            //create(if TaskID absent) or update task
            if (int.TryParse(Request.QueryString["TaskID"], out taskID))
            {
                if (!T_TASKservice.IsTaskExists(context, taskID))
                {
                    return;
                }
                T_TASK task = T_TASKservice.GetTaskByID(context, taskID);
                task.GoalID      = goalID;
                task.TaskName    = taskName;
                task.Description = description;
                task.Done        = isDone;
                task.UpdateDate  = DateTime.Now;
            }
            else
            {
                T_TASK newTask = new T_TASK {
                    GoalID = goalID, TaskName = taskName, Description = description, Done = isDone, UpdateDate = DateTime.Now, T_GOAL = goal
                };
                context.T_TASK.Add(newTask);
            }
            context.SaveChanges();
            Response.Redirect("~/_GoalPage.aspx?GoalID=" + goalID);
        }
Example #15
0
        public static T_GOAL AddNewGoal(MyDataModel db, string email, T_ACCOUNT account)
        {
            T_GOAL newGoal = new T_GOAL {
                Email = email, T_ACCOUNT = account, Done = false, GoalName = "New Goal", CreateDate = DateTime.Now
            };

            db.T_GOAL.Add(newGoal);
            db.SaveChanges();
            return(newGoal);
        }
Example #16
0
 /// <summary>
 /// Función que permite agregar una tabla al DataModelDocumentWpf.
 /// </summary>
 /// <param name="newTable">Tabla a ser agregada.</param>
 public void AddTable(TableWpf newTable)
 {
     if (newTable == null)
     {
         throw new ArgumentNullException("newTable", "newTable can not be null");
     }
     MyDataModel.AddTable(newTable);
     AttachWidgetEvent(newTable);
     canvasDraw.Children.Add(newTable.UIElement);
 }
Example #17
0
        MyDataModel MainReducer(MyDataModel prev, object action)
        {
            bool changed     = false;
            var  subSection1 = prev.subSection1.Mutate(action, MyDataModelSubSection1Reducer, ref changed);

            if (changed)
            {
                return(new MyDataModel(subSection1));
            }
            return(prev);
        }
Example #18
0
 /// <summary>
 /// Función que permite eliminar una tabla desde el DataModelDocumentWpf
 /// </summary>
 /// <param name="table">Tabla a ser eliminada.</param>
 public void RemoveTable(TableWpf table)
 {
     if (table == null)
     {
         throw new ArgumentNullException("table", "table can not be null");
     }
     RemoveRelatedRelation(table);
     MyDataModel.RemoveTable(table);
     this.canvasDraw.Children.Remove(table.UIElement);
     RedrawConnections();
 }
    private void Vc_Tapped(object sender, EventArgs e)
    {
        ViewCell    vc      = (ViewCell)sender;
        MyDataModel dm      = (MyDataModel)vc.BindingContext;
        MyDataModel currSel = vm.Data.FirstOrDefault(d => d.Selected == true);

        if (currSel != null)
        {
            currSel.Selected = false;
        }
        dm.Selected = true;
    }
Example #20
0
        static void Main(string[] args)
        {
            string filename = "test02.TXT";

            string[] lines = new string[] { };

            if (File.Exists(filename))
            {
                lines = File.ReadAllLines(filename);
            }

            foreach (var line in lines)
            {
                int num = int.Parse(line.Substring(0, 3));
                if (num == 695 || num == 525)
                {
                    var      tick = line.Substring(0, 13);
                    var      date1 = line.Substring(13, 4) + "/" + line.Substring(17, 2) + "/" + line.Substring(19, 2) + " 00:00:00";
                    var      date2 = line.Substring(21, 4) + "/" + line.Substring(25, 2) + "/" + line.Substring(27, 2) + " 00:00:00";
                    DateTime fly, birth;
                    DateTime.TryParse(date1.ToString(), out fly);
                    DateTime.TryParse(date2.ToString(), out birth);

                    //Console.WriteLine(fly);
                    //Console.WriteLine(birth);

                    try
                    {
                        MyDataModel myData = new MyDataModel();
                        myData.TimeTable.Add(new TimeTable()
                        {
                            TickNumber = tick, FlyingDay = fly, BirthDay = birth
                        });
                        myData.SaveChanges();
                        Console.WriteLine("Success");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                }
            }

            var list = (new MyDataModel()).TimeTable.ToList();

            foreach (var item in list)
            {
                Console.WriteLine($"{item.Id} {item.TickNumber} {item.FlyingDay} {item.BirthDay}");
            }

            Console.ReadLine();
        }
Example #21
0
        protected void tbxGoalName_TextChanged(object sender, EventArgs e)
        {
            int         goalID      = int.Parse(Request.QueryString["GoalID"]);
            MyDataModel context     = new MyDataModel();
            string      newGoalName = tbxGoalName.Text;

            if (string.IsNullOrEmpty(newGoalName))
            {
                newGoalName = "noname";
            }
            T_GOALservice.GetGoalByID(context, goalID).GoalName = newGoalName;
            context.SaveChanges();
        }
        public ActionResult Index(MyDataModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    User user = userBusiness.Get.FirstOrDefault(u => u.sID == AuthProvider.UserAntenticated.sID);
                    user.nome = model.nome;
                    if (!string.IsNullOrEmpty(model.senha) || !string.IsNullOrEmpty(model.confirmarSenha))
                    {
                        if (model.senha != model.confirmarSenha)
                        {
                            throw new InvalidOperationException("Senhas não conferem!");
                        }
                        if (model.senha.Length < 5)
                        {
                            throw new InvalidOperationException("Senha deve ter no mínimo 5 caracteres!");
                        }
                        user.senha = model.senha;
                    }
                    userBusiness.Update(user);

                    return(Json(new
                    {
                        Sucesso = true,
                        Mensagem = "Informações atualizadas!",
                        Titulo = "Sucesso"
                    }));
                }
                catch (Exception ex)
                {
                    string sErro = ex.Message;
                    if (ex.InnerException != null)
                    {
                        sErro += " - " + ex.InnerException.Message;
                    }
                    TempData["mensagemErroAlterarConta"] = sErro;
                    return(Json(new
                    {
                        Sucesso = false,
                        Mensagem = sErro,
                        Titulo = "Erro"
                    }));
                }
            }
            else
            {
                return(View(model));
            }
        }
    public void LoadingMyDataAndView()
    {
        // Controller I use to get whatever data I need from ex: SQL
        _myDataModel = new MyDataModel();

        // the view / window / control I want to present to users
        _myView = new MyView();

        // Now, set the data context on the view to THIS ENTIRE OBJECT.
        // Now, anything on THIS class made as public can be have a binding
        // directly to the control in the view.  Since the DataContext is
        // set here, I can bind to anything at this level or lower that is public.
        _myView.DataContext = this;
    }
Example #24
0
        public bool UpdateMyData(MyDataModel myDataModel)
        {
            bool isSave = true;

            try
            {
                _myDataRepository.UpdateMyData(myDataModel.ToEntity());
            }
            catch (Exception ex)
            {
                isSave = false;
            }

            return(isSave);
        }
        public IActionResult Put(int id, [FromBody] MyDataModel value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var entity = _repo.Read(p => p.Id == id);

            entity.Description = value.Description;
            _repo.Update(entity);
            _repo.SaveChanges();

            return(Get(entity.Id));
        }
        public IActionResult Post([FromBody] MyDataModel value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var entity = new MyDataSet()
            {
                Description = value.Description
            };

            _repo.Create(entity);
            _repo.SaveChanges();

            return(Get(entity.Id));
        }
 public void OnDataChange(DataSnapshot snapshot)
 {
     if (snapshot.Value != null)
     {
         var child = snapshot.Children.ToEnumerable <DataSnapshot>();
         dataList.Clear();
         foreach (DataSnapshot myData in child)
         {
             MyDataModel datas = new MyDataModel();
             datas.MyData = myData.Child("Data").Value.ToString();
             dataList.Add(datas);
         }
         MyDataRetrived.Invoke(this, new MyDataEventArgs {
             Data = dataList
         });
     }
 }
Example #28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.User.Identity.IsAuthenticated)
            {
                FormsAuthentication.SignOut();
                FormsAuthentication.RedirectToLoginPage();
            }

            MyDataModel context = new MyDataModel();

            int  goalID      = 0;
            bool isGetGoalID = int.TryParse(Request.QueryString["GoalID"], out goalID);

            lblHiddenGoalID.Text = goalID.ToString();

            if (!IsPostBack)
            {
                if (isGetGoalID && goalID != 0)
                {
                    tbxGoalName.Visible = true;
                    T_GOAL currentGoal    = T_GOALservice.GetGoalByID(context, goalID);
                    string actualUserName = Page.User.Identity.Name;

                    if (currentGoal == null)
                    {
                        BadGoalID(Messages.errorMissingGoalID);
                        return;
                    }
                    else if (currentGoal.T_ACCOUNT.Email != actualUserName)
                    {
                        BadGoalID(Messages.errorIncorrectGoalID);
                        return;
                    }
                    else
                    {
                        tbxGoalName.Text = currentGoal.GoalName;
                    }
                }
                else
                {
                    BadGoalID(Messages.errorMissingGoalID);
                }
                BindData();
            }
        }
Example #29
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            MyDataModel context = new MyDataModel();

            foreach (GridViewRow row in GridView1.Rows)
            {
                //Searching CheckBox("chkDel") in an individual row of Grid
                CheckBox chkTask = (CheckBox)row.FindControl("chkTask");
                //If CheckBox is checked than delete the record with particular empid
                if (chkTask.Checked)
                {
                    int taskID = int.Parse(((Label)row.FindControl("HiddenTaskID")).Text.Trim());
                    T_TASKservice.RemoveTaskByID(context, taskID);
                }
            }

            BindData();
        }
Example #30
0
        public override IEnumerator RunTest()
        {
            var testTracker = new TestAppFlowTracker();

            AppFlow.instance = testTracker;
            AppFlow.instance.ActivateLinkMapTracking();
            AppFlow.instance.ActivatePrefabLoadTracking();
            AppFlow.instance.ActivateUiEventTracking();
            AppFlow.instance.ActivateViewStackTracking();

            setupImmutableDatastore();
            // In setupImmutableDatastore() Log.MethodEntered is used, so there must be a recorded method:
            Assert.AreEqual(1, testTracker.recordedEvents.Count(x => x.category == EventConsts.catMethod));
            // In setupImmutableDatastore() the datastore will be set as a singleton:
            Assert.AreEqual(1, testTracker.recordedEvents.Count(x => x.action.Contains("DataStore")));

            var store = MyDataModel.GetStore();

            Assert.NotNull(store);
            store.Dispatch(new ActionSetBool1()
            {
                newB = true
            });
            store.Dispatch(new ActionSetString1 {
                newS = "abc"
            });
            Assert.AreEqual(true, store.GetState().subSection1.bool1);
            Assert.AreEqual("abc", store.GetState().subSection1.string1);
            // After the 2 mutations, there should be 2 mutation AppFlow events recorded:
            Assert.AreEqual(2, testTracker.recordedEvents.Count(x => x.category == EventConsts.catMutation));

            var presenter = new MyDataModelPresenter();

            presenter.targetView = gameObject;
            yield return(presenter.LoadModelIntoView(store).AsCoroutine());

            // After the presenter loaded the UI there should be a load start and load end event recorded:
            Assert.AreEqual(2, testTracker.recordedEvents.Count(x => x.category == EventConsts.catPresenter));
            // The MyDataModelPresenter uses a GetLinkMap() when connecting to the view:
            Assert.AreEqual(1, testTracker.recordedEvents.Count(x => x.category == EventConsts.catLinked));

            yield return(new WaitForSeconds(1));
        }