public ResponseModel <IEnumerable <GroupModel> > Get()
        {
            var resp = new ResponseModel <IEnumerable <GroupModel> >();

            try
            {
                var appList = AppRepo.GetGroupsModel().ToList();

                if (appList.Any())
                {
                    resp.Data        = appList;
                    resp.Status      = 200;
                    resp.Description = "OK";
                }
                else
                {
                    resp.Status      = 200;
                    resp.Description = "No groups";
                    resp.Data        = null;
                }
            }
            catch (Exception ex)
            {
                resp.Status      = 500;
                resp.Description = $"Error: {ex.Message}";
                resp.Data        = null;
            }

            return(resp);
        }
Example #2
0
        private async Task <FoodItemsDataModel> getDatafromServerAsync()
        {
            AppRepo appRepo = new AppRepo();
            var     data    = DatabaseOperations.getToken();

            return(await appRepo.getFoodItemsFromServer(data.token));
        }
Example #3
0
        protected override void AfterInitialized()
        {
            base.AfterInitialized();

            cbStati.Items.Clear();
            foreach (EMailState v in Enum.GetValues(typeof(EMailState)))
            {
                cbStati.Items.Add(new ComboboxItem <EMailState>(v, v.DescriptionAttr()));
            }

            cbStati.SelectedIndex = 0;

            SetNodeSelectionEvidenceIntreeview(treeView1);

            _scheduler = new JobsScheduler(AppRepo, AppSvc);
            _scheduler.OnSentMailEvent += OnSentMailEvent;

            var jobs = AppRepo.GetJobs().OrderBy(x => x.Nome.ToLower());

            AddNodes(jobs);
            if (treeView1.Nodes.Count > 0)
            {
                treeView1.SelectedNode = treeView1.Nodes[0];
            }
            else
            {
                treeView1_AfterSelect(this, null);
            }
        }
Example #4
0
        public void setup()
        {
            codeRepo = new PhoneCodeRepo();
            codeRepo.add(new PhoneCD { PHONE_CD = "AA", PHONE_TX = "Home", MOD_DT = DateTime.Now });
            codeRepo.add(new PhoneCD { PHONE_CD = "BB", PHONE_TX = "Mobile", MOD_DT = DateTime.Now });
            codeRepo.add(new PhoneCD { PHONE_CD = "CC", PHONE_TX = "Batphone", MOD_DT = DateTime.Now });

            /*
             * Add the logic here to create a new AppRepo() and then add an applicant with an
             * applicant_id of 1. When you do this, the next part should work.
             */

            /*            phoneRepo = new PhoneRepo();
            phoneRepo.add(new Phone { PHONE_CD = "AA", PHONE_TX = 5028011112, MOD_DT = DateTime.Now, APPLICANT_ID = 1, CREATE_DT = DateTime.Now });
            phoneRepo.add(new Phone { PHONE_CD = "BB", PHONE_TX = 5028011113, MOD_DT = DateTime.Now, APPLICANT_ID = 2, CREATE_DT = DateTime.Now });
            phoneRepo.add(new Phone { PHONE_CD = "CC", PHONE_TX = 5028011114, MOD_DT = DateTime.Now, APPLICANT_ID = 3, CREATE_DT = DateTime.Now });
            */
                        appRep = new AppRepo();
            appRep.add(new Applicant {
                APPLICANT_ID = 1, FIRST_NAME_TX = "John", LAST_NAME_TX = "Stinson", MIDDLE_INITIAL_TX = "C",
                MOD_DT = DateTime.Now, SSN_TX = "901111134", SUFFIX_TX = "" }
            );

            phoneRepo = new PhoneRepo();
            phoneRepo.add(new Phone { PHONE_CD = "AA", PHONE_TX = 5021111111, MOD_DT = DateTime.Now, APPLICANT_ID = 1, CREATE_DT = DateTime.Now });
            phoneRepo.add(new Phone { PHONE_CD = "BB", PHONE_TX = 5021234567, MOD_DT = DateTime.Now, APPLICANT_ID = 1, CREATE_DT = DateTime.Now });
            phoneRepo.add(new Phone { PHONE_CD = "CC", PHONE_TX = 5027891011, MOD_DT = DateTime.Now, APPLICANT_ID = 1, CREATE_DT = DateTime.Now });
        }
Example #5
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (treeView1.SelectedNode == null)
            {
                _elencoMailInInvio       = new ObservableCollection <MailToSend>(new List <MailToSend>());
                dataGridView1.DataSource = _elencoMailInInvio;
            }
            else
            {
                var list = AppRepo.GetMailsDelJob(CurrentJobId).OrderBy(x => x.Address?.ToLower()).ToList();

                var destinatari = AppSvc.GetDestinatariDelRecipienteCorrente();
                list.AddRange(destinatari.Select(x => new MailToSend()
                {
                    Id      = Guid.NewGuid().ToString("N"),
                    Address = x.Address,
                    Nome    = x.Nome,
                    IdJob   = CurrentJobId
                }));

                var lookup = list.ToLookup(x => x.Address?.ToLower());
                lookup.Where(x => x.Count() > 1)
                .ToList()
                .ForEach(x =>
                {
                    foreach (var m in x.Where(ss => ss.State == null))
                    {
                        list.RemoveAll(k => k.Id == m.Id);
                    }
                });

                _elencoMailInInvio       = new ObservableCollection <MailToSend>(list);
                dataGridView1.DataSource = _elencoMailInInvio;
            }
        }
Example #6
0
        private async void processData()
        {
            string username = this.UsernameTextBox.Text;
            string password = this.passwordTextBox.Text;

            AppRepo repo = new AppRepo();

            if (NetworkConnectivity.DnsTest())
            {
                isBusy(true);
                var data = await repo.loginUser(new LoginDataModel { email = username, password = password });

                if (data != null && data.status)
                {
                    DatabaseOperations.saveToken(data);
                    this.Hide();
                    var mainform = new MainForm();
                    mainform.Closed += (s, args) => this.Close();
                    mainform.Show();
                }
                else
                {
                    isBusy(false);
                    errorProvider1.SetError(this.UsernameTextBox, "Login was not successful. Try again later");
                    return;
                }
            }
            else
            {
                MessageBox.Show(Constants.INTERNET_CONNECTION_ERR_MSG, Constants.INTERNET_CONNECTION_ERROR);
                return;
            }
        }
Example #7
0
        private TreeNode CreaNuovoSenderJob(string nome)
        {
            var job = AppRepo.AddSenderJob(nome);

            AddNodes(new[] { job });
            return(treeView1.Nodes.OfType <TreeNode>().Single(x => x.Tag == job.Id));
        }
Example #8
0
        private TreeNode CreaNuovoRecipiente(string nome)
        {
            var recipiente = AppRepo.AddRecipiente(nome);

            AddNodes(new[] { recipiente });
            return(treeView1.Nodes.OfType <TreeNode>().Single(x => x.Tag == recipiente.Id));
        }
        public ResponseModel <bool> Delete(int id)
        {
            var resp = new ResponseModel <bool>();

            try
            {
                if (id == 0)
                {
                    throw new Exception("Id not found");
                }

                var groupObj = AppRepo.GetById(id);

                if (groupObj != null)
                {
                    AppRepo.Delete(groupObj);

                    resp.Status      = 200;
                    resp.Data        = true;
                    resp.Description = "OK";
                }
                else
                {
                    throw new Exception("id not exist");
                }
            }
            catch (Exception ex)
            {
                resp.Status      = 500;
                resp.Description = $"Error: {ex.Message}";
                resp.Data        = true;
            }

            return(resp);
        }
        public ResponseModel <GroupModel> GetById(int id)
        {
            var resp = new ResponseModel <GroupModel>();

            try
            {
                var app = AppRepo.GetGroupModelById(id);

                if (app != null)
                {
                    resp.Data        = app;
                    resp.Status      = 200;
                    resp.Description = "OK";
                }
                else
                {
                    resp.Status      = 200;
                    resp.Data        = null;
                    resp.Description = "Group not found";
                }
            }
            catch (Exception ex)
            {
                resp.Status      = 500;
                resp.Description = $"Error: {ex.Message}";
                resp.Data        = null;
            }

            return(resp);
        }
Example #11
0
        private TreeNode CreaNuovaMail(string nome)
        {
            var mail = AppRepo.AddMail(nome);

            AddNodes(new[] { mail });
            return(treeView1.Nodes.OfType <TreeNode>().Single(x => x.Tag == mail.Id));
        }
        public ResponseModel <int> Post([FromBody] GroupModel dataToAdd)
        {
            var resp = new ResponseModel <int>();

            try
            {
                if (dataToAdd == null)
                {
                    throw new Exception("Data is null");
                }

                var model = new Group
                {
                    Name          = dataToAdd.Name,
                    Description   = dataToAdd.Description,
                    IsActive      = dataToAdd.IsActive,
                    IsDelete      = dataToAdd.IsDelete,
                    Date          = dataToAdd.Date,
                    LogoUrl       = dataToAdd.LogoUrl,
                    IdUserCreator = dataToAdd.IdUserCreator
                };

                if (string.IsNullOrEmpty(model?.LogoUrl))
                {
                    model.LogoUrl = string.Empty;
                }

                if (AppRepo.Insert(model))
                {
                    var modelUg = new UserGroup()
                    {
                        IdUser  = model.IdUserCreator,
                        IdGroup = model.Id
                    };

                    if (UserGroupRepo.Insert(modelUg))
                    {
                        resp.Data        = model.Id;
                        resp.Status      = 200;
                        resp.Description = "OK";
                    }
                    else
                    {
                        throw new Exception("No user added to group");
                    }
                }
                else
                {
                    throw new Exception("Not inserted");
                }
            }
            catch (Exception ex)
            {
                resp.Status      = 500;
                resp.Description = $"Error: {ex.Message}";
                resp.Data        = 0;
            }

            return(resp);
        }
Example #13
0
 public RecordsController(
     AppRepo appRepo,
     RecordRepo recordRepo)
 {
     _appRepo    = appRepo;
     _recordRepo = recordRepo;
 }
Example #14
0
 private void dataGridView1_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
 {
     if (dataGridView1.IsCurrentRowDirty)
     {
         var d = _elencoDestintari[e.RowIndex];
         AppRepo.UpdateDestinatario(d);
     }
 }
Example #15
0
 public SitesController(
     AppRepo appRepo,
     FolderRepo folderRepo,
     SiteRepo siteRepo)
 {
     _appRepo    = appRepo;
     _folderRepo = folderRepo;
     _siteRepo   = siteRepo;
 }
Example #16
0
 public void Delete([FromBody] IEnumerable <int> recordsForDelete)
 {
     if (AuthRepo.IsAuthenticated())
     {
         Response.StatusCode = AppRepo.DeleteRecords(AuthRepo.CurrentUserId, recordsForDelete);
         return;
     }
     Response.StatusCode = 401;
 }
Example #17
0
        public void Delete([FromBody] IEnumerable <int> usersForDelete)
        {
            if (AuthRepo.IsAuthenticated(Role.Admin))
            {
                Response.StatusCode = AppRepo.DeleteUsers(usersForDelete);
                return;
            }

            Response.StatusCode = 401;
        }
Example #18
0
        // GET: Home
        public ActionResult Index()
        {
            var repo = new AppRepo();

            var list = repo.GetMetadataItems();

            // List<MediaItem> files = context.MediaItems.ToList();

            return(View(list));
        }
Example #19
0
        public void Put([FromBody] IEnumerable <RecordPutModel> records)
        {
            if (AuthRepo.IsAuthenticated())
            {
                Response.StatusCode = AppRepo.ChangeRecords(AuthRepo.CurrentUserId, records);
                return;
            }

            Response.StatusCode = 401;
        }
Example #20
0
        public void Delete()
        {
            if (AuthRepo.IsAuthenticated())
            {
                Response.StatusCode = AppRepo.DeleteAllRecords(AuthRepo.CurrentUserId);
                return;
            }

            Response.StatusCode = 401;
        }
Example #21
0
        private void btnSalva_Click(object sender, EventArgs e)
        {
            var html      = editorForm1.GetHtmlText();
            var plainText = editorForm1.GetPlainText();
            var subj      = tbSubject.Text;

            if (!string.IsNullOrWhiteSpace(CurrentMailId))
            {
                AppRepo.UpdateMail(CurrentMailId, subj, html, plainText);
            }
        }
Example #22
0
        public IActionResult Get()
        {
            if (AuthRepo.IsAuthenticated())
            {
                var package = AppRepo.GetAllRecordsAsExcel(AuthRepo.CurrentUserId);
                return(File(package.GetAsByteArray(), XlsxContentType, "records.xlsx"));
            }

            Response.StatusCode = 401;
            return(Json(new { Msg = "Unauthorized " }));
        }
Example #23
0
 public JsonResult Get([FromQuery] string search, [FromQuery] int offset = 0, [FromQuery] int limit = 3)
 {
     if (AuthRepo.IsAuthenticated(Role.Admin))
     {
         int count;
         var users = AppRepo.GetAllUsers(offset, limit, search, out count);
         return(Json(new { Count = count, Users = users }));
     }
     Response.StatusCode = 401;
     return(Json(new { Msg = "Unauthorized" }));
 }
Example #24
0
 public JsonResult Get([FromQuery] int offset = 0, [FromQuery] int limit = 3)
 {
     if (AuthRepo.IsAuthenticated())
     {
         int count;
         var records = AppRepo.GetAllRecords(
             AuthRepo.CurrentUserId, limit, offset, out count);
         return(Json(new { Count = count, Records = records }));
     }
     Response.StatusCode = 401;
     return(Json(new { Msg = "Unauthorized" }));
 }
Example #25
0
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 2)
     {
         if (e.RowIndex >= 0)
         {
             var d = _elencoDestintari[e.RowIndex];
             AppRepo.RemoveDestinatario(d.Id);
             _elencoDestintari.RemoveAt(e.RowIndex);
         }
     }
 }
Example #26
0
        private void StartJob()
        {
            foreach (var mailToSend in _elencoMailInInvio.Where(x => !x.State.HasValue))
            {
                mailToSend.State = EMailState.DaInviare;
            }
            Update();
            tbLog.AppendText("Start job invio..." + Environment.NewLine);

            AppRepo.UpdateMailsToSendOfJob(CurrentJobId, _elencoMailInInvio);
            var cfg = AppRepo.LoadSmtpConfig();

            _scheduler.StartJob(CurrentJobId, cfg);
        }
Example #27
0
 private void treeView1_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(e.Label))
     {
         e.CancelEdit = true;
     }
     else
     {
         if (!string.IsNullOrWhiteSpace(CurrentJobId))
         {
             AppRepo.UpdateSenderJobNome(CurrentJobId, e.Label);
         }
     }
 }
Example #28
0
 public JsonResult Post([FromBody] RecordPostModel recordModel)
 {
     // Admin and Client can access
     if (AuthRepo.IsAuthenticated())
     {
         User   currentUser = AppRepo.GetUserById(AuthRepo.CurrentUserId);
         int    status;
         string msg;
         AppRepo.AddRecord(currentUser, recordModel, out status, out msg);
         Response.StatusCode = status;
         return(Json(new { Msg = msg }));
     }
     Response.StatusCode = 401;
     return(Json(new { Msg = "Unauthorized" }));
 }
Example #29
0
 private void treeView1_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(e.Label))
     {
         e.CancelEdit = true;
     }
     else
     {
         var idMail = (string)treeView1.SelectedNode?.Tag;
         if (!string.IsNullOrWhiteSpace(idMail))
         {
             AppRepo.UpdateMailNome(idMail, e.Label);
         }
     }
 }
Example #30
0
        // GET: Home
        public ActionResult Index()
        {
            var repo = new AppRepo();


            var list = repo.GetMetadataItems();

            // List<MetadataItem> files = context.Me.ToList();

            //var cars = HelloModel.GetCars();

            //ViewBag.PeterCreatedThisValue = "My value";

            return(View(list));
        }
Example #31
0
        protected override void AfterInitialized()
        {
            base.AfterInitialized();

            var recipienti = AppRepo.GetRecipienti().OrderBy(x => x.Nome.ToLower());

            AddNodes(recipienti);
            if (treeView1.Nodes.Count > 0)
            {
                treeView1.SelectedNode = treeView1.Nodes[0];
            }
            else
            {
                treeView1_AfterSelect(this, null);
            }
        }
Example #32
0
        public void setup()
        {
            aRepo = new AppRepo();
            a1 = new Applicant
            {
                APPLICANT_ID = 1,
                FIRST_NAME_TX = "John",
                LAST_NAME_TX = "Stinson",
                MIDDLE_INITIAL_TX = "C",
                MOD_DT = DateTime.Now,
                SSN_TX = "123456789",
                SUFFIX_TX = ""
            };
            aRepo.add(a1);

            a2 = new Applicant
              {    APPLICANT_ID = 2,
                FIRST_NAME_TX = "Trina",
                LAST_NAME_TX = "Stinson",
                MIDDLE_INITIAL_TX = "R",
                MOD_DT = DateTime.Now,
                SSN_TX = "987654321",
                SUFFIX_TX = ""

              };
            aRepo.add(a2);

            aRepo.add(new Applicant
            {
                APPLICANT_ID = 3,
                FIRST_NAME_TX = "Pancake",
                LAST_NAME_TX = "TheCat",
                MIDDLE_INITIAL_TX = "C",
                MOD_DT = DateTime.Now,
                SSN_TX = "111111122",
                SUFFIX_TX = ""
            });
        }