Exemple #1
0
 /// <summary>
 /// 以下已废弃
 /// </summary>
 public void AddContestResult(int contest_id)
 {
     //foreach user in detail
     //get rating
     List<CfContestResult> list_fetch = new List<CfContestResult>();
     var crudResult = new Crud<CfResult>();
     var crudDetail = new Crud<CfDetail>();
     //crud.Query("Nickname",
 }
Exemple #2
0
 public IEnumerable<ajt_collaborator> GetCollaboratorsForEmploye(IEnumerable<ajt_collaborator> ajt_coll)
 {
     List<ajt_collaborator> aj_coll_result = new List<ajt_collaborator>();
     foreach (ajt_collaborator item in ajt_coll)
     {
         ICrud<aspnetuser> crud = new Crud<aspnetuser>();
         List<aspnetuser> users = crud.GetAll().ToList();
         aspnetuser user = users.Where(x => x.Id == item.id_user_fk).FirstOrDefault();
         List<aspnetrole> liste = user.aspnetroles.ToList();
         if (liste.Count > 0) {
         aspnetrole  rule = liste[0];
         if (rule.Name.Contains("chauffeur")) aj_coll_result.Add(item);
         }
     }
     return aj_coll_result.OrderByDescending(x => x.id);
 }
 public void AddContestInfo(int contest_id)
 {
     var info = cf.GetContestInfo(contest_id);
     Crud<Info> crud = new Crud<Info>();
     Info tmp = new Info();
     tmp.AllNum = info.allnum;
     tmp.ContestId = info.ContestId;
     tmp.Divc = info.div;
     tmp.Type = "CF";
     tmp.ContestName = info.ContestName;
     //tmp.ContestType
     //tmp.ContestDate
     crud.Insert(tmp);
     //等待插入数据库info表
     //时间有待手动添加
 }
        private void btnAddType2_Click(object sender, EventArgs e)
        {
            Types        oTypes = new Types();
            List <Types> lTypes = new List <Types>();

            oTypes.sTypeName  = inptAddTypeName.Text;
            oTypes.sTypeValue = inptAddTypeValue.Text;

            Crud oCrud = new Crud();

            oCrud.SaveNewType(oTypes);

            this.FormTypeList.dataGridViewTypes.DataSource = oCrud.GetAllTypes();
            lTypes = oCrud.GetAllTypes();
            List <string> lType = lTypes.Where(o => o.sTypeValue != "").Select(o => o.sTypeValue).Distinct().ToList();

            this.FormTypeList.comboBoxType.DataSource = lType;
            this.Hide();
        }
        private int EditData()
        {
            if (this.txtName.Text == String.Empty)
            {
                MessageBox.Show("Name field is empty.", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            if (this.txtEmail.Text == String.Empty)
            {
                MessageBox.Show("Email field is empty.", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            if (this.txtSalary.Text == String.Empty)
            {
                MessageBox.Show("Salary field is empty.", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            char genre;

            if (rdMale.Checked)
            {
                genre = 'M';
            }
            else
            {
                genre = 'F';
            }

            int return_op = Crud.Edit_PhysicalPerson(this.id, this.txtName.Text.Trim(), this.txtEmail.Text.Trim(), Decimal.Parse(this.txtSalary.Text), this.dtDateBirth.Value, genre);

            if (return_op == 1)
            {
                return(return_op);
            }
            else
            {
                MessageBox.Show("Error editing Physical Person record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(return_op);
            }
        }
        public static Pizza GetPizzaPrice(string pizzaType, string size, string crust)
        {
            List <Pizza> pizzas = new Crud().GetPizzas();
            Pizza        piz    = new Pizza();

            Console.WriteLine();

            foreach (Pizza pizza in pizzas)
            {
                //break the condition down
                if (pizza.PType.ToLower().Equals(pizzaType.ToLower()) &&
                    pizza.PSize.ToLower().Equals(size.ToLower()) && pizza.Crust.ToLower().Equals(crust.ToLower()))
                {
                    piz = pizza;
                }
            }

            return(piz);
        }
        private void button3_Click(object sender, EventArgs e)
        {
            ISession s = DataLayer.GetSession();

            try
            {
                Crud <Izvestaj> .Delete(s, int.Parse(textBox5.Text));

                neaktivno();
                textBox9.Text = "";
                textBox8.Text = "";
                textBox7.Text = "";
                textBox6.Text = "";
                textBox5.Text = "";
            }
            catch (Exception ex)
            {
            }
        }
        private void button7_Click(object sender, EventArgs e)
        {
            Tim t = new Tim
            {
                Ime      = textBox9.Text,
                Studenti = listaStudenata
            };

            t.BrojClanova = int.Parse(textBox10.Text);

            ISession s = DataLayer.GetSession();

            Crud <Tim> .Create(s, t);

            s.Close();

            textBox9.Text  = "";
            textBox10.Text = "";
        }
Exemple #9
0
        public CardEditor()
        {
            InitializeComponent();


            const string ConnectionString = "mongodb://*****:*****@test-shard-00-00-imtir.mongodb.net:27017,test-shard-00-01-imtir.mongodb.net:27017,test-shard-00-02-imtir.mongodb.net:27017/test?ssl=true&replicaSet=test-shard-0&authSource=admin&retryWrites=true";

            MongoDbConnection.InitializeAndStartConnection(ConnectionString, databaseName: "MilitaryTCG");

            _keywordCrud = new Crud <Keyword>();
            _cardCrud    = new Crud <Card>();
            _crudFaction = new Crud <Faction>();

            _cardInfoPage = new CardInfoPage(FillFactionComboBox());

            FillRarityComboBox();
            FillCombobox();
            FillListBox();
        }
        public FormPoveziSaProjektom()
        {
            trenutnoIzabraniTim = -1;
            InitializeComponent();
            textBox1.ReadOnly = true;
            ISession s = DataLayer.GetSession();

            dataGridView1.DataSource = Crud <Tim> .ReturnAll(s);

            dataGridView2.DataSource = Crud <Projekat> .ReturnAll(s);

            dataGridView1.Columns[0].Visible = false;
            dataGridView1.Columns[3].Visible = false;
            dataGridView1.Columns[4].Visible = false;
            dataGridView2.Columns[4].Visible = false;
            dataGridView2.Columns[5].Visible = false;
            dataGridView2.Columns[0].Visible = false;
            s.Close();
        }
        private void Excluir(Aluno aluno)
        {
            Crud crud = new Crud();

            if (txtMatricula.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Selecione um aluno para excluir!", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if ((MessageBox.Show("Deseja realmente excluir?", "Alerta", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No))
            {
            }
            else
            {
                aluno.Matricula = int.Parse(txtMatricula.Text);
                crud.Excluir(aluno);
                MessageBox.Show("Aluno excluído com sucesso!!");
                Listar();
            }
        }
        public void AddContestRating(string user_id)
        {
            Crud<Rating> crud=new Crud<Rating>();
            Rating rating=new Rating();
            var users = cf.GetAllContestResults(user_id);
            foreach (var tmp in users)
            {
                rating.ContestId = tmp.ContestId;
                rating.Contestname = tmp.ContestName;
                rating.Username = tmp.UserName;
                rating.Rank = tmp.Rank;
                rating.RaTing = tmp.Rating;
                rating.Timesplayed = tmp.Timesplayed;
                rating.Type = "CF";
                crud.Insert(rating);
            }

            //有待插入tb_contest_rating表
        }
Exemple #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "Book";

            if (Request.IsAuthenticated)
            {
                if (!this.IsPostBack)
                {
                    AuthorBook authorBook = Crud.GetBookByISBN(Request.QueryString["ISBN"]);
                    if (authorBook != null)
                    {
                        id = authorBook.Author.Id;
                        this.lblArtisticName.Text = authorBook.Author.ArtisticName;

                        /************************************************/

                        this.lblTitle.Text = authorBook.Book.Title;
                        isbn = authorBook.Book.Isbn;
                        this.lblISBN.Text  = authorBook.Book.Isbn;
                        this.lblPage.Text  = authorBook.Book.Page.ToString();
                        this.lblPrice.Text = authorBook.Book.Price.ToString();

                        var base64 = Convert.ToBase64String(authorBook.Book.Picture);
                        var imgSrc = String.Format("data:image/gif;base64,{0}", base64);
                        this.imgPictureBookDetail.ImageUrl = imgSrc;

                        this.hplnkRetDet.NavigateUrl  = "../../Registration/Authors/Details.aspx?Id=" + id;
                        this.hplnkEditDet.NavigateUrl = "../../Registration/Books/Edit.aspx?ISBN=" + isbn;

                        /************************************************/
                    }
                    else
                    {
                        Response.Redirect("Authors/Search.aspx");
                    }
                }
            }
            else
            {
                Response.Redirect("~/Account/Login.aspx");
            }
        }
Exemple #14
0
        /// <summary>
        /// Validates the user ID in the context.
        /// </summary>
        /// <param name="crud">
        /// The CRUD operation for which a token is being created.
        /// </param>
        /// <returns>
        /// The ResultCode corresponding to the result of the operation.
        /// </returns>
        /// <remarks>
        /// Authenticated user is automatically created within the system if necessary when validating the user ID in the
        /// context while obtaining a token for Create operations.
        /// </remarks>
        private ResultCode ValidateUserId(Crud crud)
        {
            ResultCode result = ResultCode.Success;

            // Attempt to retrieve the user.
            SharedUserLogic sharedUserLogic = new SharedUserLogic(Context, CommerceOperationsFactory.UserOperations(Context));
            User            user            = sharedUserLogic.RetrieveUser();

            // If the user is null and the CRUD operation is Create, implicitly create the user.
            if (user == null)
            {
                if (crud == Crud.Create)
                {
                    if (Context.ContainsKey(Key.CorrelationId) == true)
                    {
                        Guid userId = (Guid)Context[Key.GlobalUserId];
                        user = new User(userId, Guid.NewGuid());
                        Context[Key.User] = user;
                        sharedUserLogic.AddUser();

                        // Update analytics.
                        Analytics.AddRegisterUserEvent(userId, user.AnalyticsEventId, (Guid)Context[Key.CorrelationId], Context[Key.ReferrerId] as string);

                        // Add referral, if any.
                        SharedReferralLogic sharedReferralLogic = new SharedReferralLogic(Context,
                                                                                          CommerceOperationsFactory.ReferralOperations(Context));
                        sharedReferralLogic.AddReferral((string)Context[Key.ReferredUserId]);
                    }
                    else
                    {
                        Context.Log.Warning("No correlation ID could be found in the context.");
                        result = ResultCode.ParameterCannotBeNull;
                    }
                }
                else
                {
                    result = ResultCode.UnexpectedUnregisteredUser;
                }
            }

            return(result);
        }
        public static String SuccessMessage(Crud crud)
        {
            string message = LanguageSub.MSG_DATA_NOT_FOUND;

            switch (crud)
            {
            case Crud.Insert:
                message = LanguageSub.MSG_INSERT_SUCCESS;
                break;

            case Crud.Update:
                message = LanguageSub.MSG_UPDATE_SUCCESS;
                break;

            case Crud.Delete:
                message = LanguageSub.MSG_DELETE_SUCCESS;
                break;
            }
            return(message);
        }
        public ActionResult DeleteProduct(int?id)
        {
            using (Crud db = new Crud())
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(400));
                }
                var product = db.Products.FirstOrDefault(x => x.Id == id);

                if (product == null)
                {
                    return(new HttpStatusCodeResult(404));
                }
                db.Products.Remove(product);
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
 public ActionResult AddProduct(Product product)
 {
     using (Crud db = new Crud())
     {
         if (ModelState.IsValid)
         {
             db.Products.Add(product);
             db.SaveChanges();
         }
         else
         {
             // Response.Write(@"<script language='javascript'>alert('Message:  \n" + "Hi!" + " .');</script>");
             // TempData["Message"] = "You are not authorized.";
             // return Json(new { Message = "Empty" });
             return(RedirectToAction("AddProduct", "Crud"));
             //return new HttpStatusCodeResult(400);
         }
     }
     return(RedirectToAction("Index"));
 }
        private void button1_Click(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                ISession s   = DataLayer.GetSession();
                int      id  = int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());
                Tim      tim = Crud <Tim> .Read(s, id);

                trenutnoIzabraniTim      = tim.Id;
                dataGridView3.DataSource = null;
                dataGridView3.Update();
                dataGridView3.Refresh();
                dataGridView3.DataSource         = tim.Projekti;
                dataGridView3.Columns[0].Visible = false;
                dataGridView3.Columns[5].Visible = false;
                dataGridView3.Columns[4].Visible = false;
                textBox1.Text = tim.Ime;
                s.Close();
            }
        }
Exemple #19
0
        public IActionResult EditDish(int EditedId, Crud update)
        {
            Crud editDish = dbContext.dishes.SingleOrDefault(e => e.CrudId == EditedId);

            if (ModelState.IsValid)
            {
                editDish.Name        = update.Name;
                editDish.Chef        = update.Chef;
                editDish.Tastiness   = update.Tastiness;
                editDish.Calories    = update.Calories;
                editDish.Description = update.Description;
                editDish.UpdatedAt   = DateTime.Now;
                dbContext.SaveChanges();
                return(RedirectToAction("Showw", new { id = EditedId }));
            }
            else
            {
                return(View("EditPage"));
            }
        }
Exemple #20
0
        public static PictureViewModel ToModel(this Picture Entity)
        {
            var Model = new PictureViewModel()
            {
                Id       = Entity.Id,
                Name     = Entity.Name,
                Url      = Entity.Url,
                Size     = (int)Entity.Size,
                Public   = (bool)Entity.Public,
                Comments = (Crud.GetCommentsFromPicture(Entity.Id)).ToModelList(),
            };

            if (Entity.AlbumRefID != null)
            {
                Model.AlbumRefID = (Guid)Entity.AlbumRefID;
            }
            ;

            return(Model);
        }
Exemple #21
0
        public Validate Validate(Repository value, Crud operation)
        {
            AtendimentoEmailRepository r = (AtendimentoEmailRepository)value;

            if (r.prospect.telefone != null)
            {
                if (r.prospect.telefone.Length < 10 && r.prospect.telefone.Length > 0)
                {
                    value.mensagem = new Validate()
                    {
                        Code    = 4,
                        Field   = "prospect.telefone",
                        Message = "Número do telefone inválido"
                    };
                    return(value.mensagem);
                }
                else
                {
                    return new Validate()
                           {
                               Code = 0, Message = MensagemPadrao.Message(0).ToString().Replace("[br]", "<br />")
                           }
                };
            }
            else if (r.msg.empreendimentoId == null)
            {
                value.mensagem = new Validate()
                {
                    Code    = 4,
                    Message = "Empreendimento deve ser informado"
                };
                return(value.mensagem);
            }
            else
            {
                return new Validate()
                       {
                           Code = 0, Message = MensagemPadrao.Message(0).ToString().Replace("[br]", "<br />")
                       }
            };
        }
Exemple #22
0
        public override Validate Validate(DocInternoViewModel value, Crud operation)
        {
            if (value.mensagem != null && value.mensagem.Code.HasValue && value.mensagem.Code > 0)
            {
                return(value.mensagem);
            }

            value.mensagem = new Validate()
            {
                Code = 0, Message = MensagemPadrao.Message(0).ToString(), MessageType = MsgType.SUCCESS
            };

            if (value.docFolderId == 0)
            {
                value.mensagem.Code        = 5;
                value.mensagem.Message     = MensagemPadrao.Message(5, "Pasta deve ser informada").ToString();
                value.mensagem.MessageBase = "Campo Pasta deve ser informado";
                value.mensagem.MessageType = MsgType.WARNING;
                return(value.mensagem);
            }

            if (value.arquivo == null || value.arquivo == "")
            {
                value.mensagem.Code        = 5;
                value.mensagem.Message     = MensagemPadrao.Message(5, "Arquivo deve ser informado").ToString();
                value.mensagem.MessageBase = "Campo arquivo deve ser informado";
                value.mensagem.MessageType = MsgType.WARNING;
                return(value.mensagem);
            }

            if (value.descricao.Trim().Length == 0)
            {
                value.mensagem.Code        = 5;
                value.mensagem.Message     = MensagemPadrao.Message(5, "Descrição do arquivo").ToString();
                value.mensagem.MessageBase = "Campo descrição deve ser informado";
                value.mensagem.MessageType = MsgType.WARNING;
                return(value.mensagem);
            }

            return(value.mensagem);
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            ClearGrid();

            if (this.rdCode.Checked)
            {
                if (this.txtDataSearch.Text != String.Empty)
                {
                    if (Crud.GetPhysicalPerson_ByID(Int32.Parse(this.txtDataSearch.Text.Trim())) != null)
                    {
                        List <PhysicalPerson> lista = new List <PhysicalPerson>();
                        lista.Add(Crud.GetPhysicalPerson_ByID(Int32.Parse(this.txtDataSearch.Text.Trim())));
                        this.GridPhysicalPerson.DataSource = lista;
                        this.GridPhysicalPerson.Visible    = true;
                    }
                    else
                    {
                        MessageBox.Show("No data found.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        ClearSearch();
                    }
                }
                else
                {
                    MessageBox.Show("Enter a code to search.", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                this.GridPhysicalPerson.DataSource = Crud.GetPhysicalPerson_ByName(this.txtDataSearch.Text.Trim());

                if (this.GridPhysicalPerson.RowCount > 0)
                {
                    this.GridPhysicalPerson.Visible = true;
                }
                else
                {
                    MessageBox.Show("No data found.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ClearSearch();
                }
            }
        }
        public override Validate Validate(GrupoCredorViewModel value, Crud operation)
        {
            value.mensagem = new Validate()
            {
                Code = 0, Message = MensagemPadrao.Message(0).ToString(), MessageType = MsgType.SUCCESS
            };

            if (value.nome.Trim().Length == 0)
            {
                value.mensagem.Code        = 5;
                value.mensagem.Message     = MensagemPadrao.Message(5, "Descrição").ToString();
                value.mensagem.MessageBase = "Campo Nome do Grupo deve ser informado";
                value.mensagem.MessageType = MsgType.WARNING;
                return(value.mensagem);
            }
            else if (operation == Crud.INCLUIR)
            {
                // Verifica se o grupo já foi cadastrado com o mesmo nome
                if (db.GrupoCredores.Where(info => info.nome == value.nome && info.CondominioID == value.CondominioID).Count() > 0)
                {
                    value.mensagem.Code        = 19;
                    value.mensagem.Message     = MensagemPadrao.Message(19).ToString();
                    value.mensagem.MessageBase = "Campo Nome do Grupo já existe";
                    value.mensagem.MessageType = MsgType.WARNING;
                    return(value.mensagem);
                }
            }
            else if (operation == Crud.ALTERAR)
            {
                // Verifica se o grupo já foi cadastrado com o mesmo nome
                if (db.GrupoCredores.Where(info => info.nome == value.nome && info.CondominioID == value.CondominioID && info.grupoCredorId != value.grupoCredorId).Count() > 0)
                {
                    value.mensagem.Code        = 19;
                    value.mensagem.Message     = MensagemPadrao.Message(19).ToString();
                    value.mensagem.MessageBase = "Campo Nome do Grupo já existe";
                    value.mensagem.MessageType = MsgType.WARNING;
                    return(value.mensagem);
                }
            }
            return(value.mensagem);
        }
Exemple #25
0
 private void FillGrid()
 {
     if (Request.IsAuthenticated)
     {
         List <Author> authors = Crud.GetAuthorByName(this.txtData.Text);
         if (authors != null)
         {
             this.gridAuthors.DataSource = authors;
             this.gridAuthors.DataBind();
         }
         else
         {
             ShowModal("Information", "No results were found with this name.");
             this.txtData.Text = "";
         }
     }
     else
     {
         Response.Redirect("~/Account/Login.aspx");
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            Izvestaj i = new Izvestaj
            {
                Opis         = textBox9.Text,
                RokPredaje   = DateTime.Parse(textBox8.Text),
                VremePredaje = DateTime.Parse(textBox7.Text)
            };

            int index            = comboBox1.SelectedIndex;
            int id               = IdProjekta[index];
            PrakticniProjekat pp = Crud <PrakticniProjekat> .Read(s, id);

            i.PrakticniProjekat = pp;

            Crud <Izvestaj> .Create(s, i);

            textBox9.Text = "";
            textBox8.Text = "";
            textBox7.Text = "";
        }
Exemple #27
0
 protected void btnSearch_Click(object sender, EventArgs e)
 {
     if (Request.IsAuthenticated)
     {
         List <Author> authors = Crud.GetAuthorByName(this.txtData.Text);
         if (authors != null)
         {
             this.gridAuthors.DataSource = authors;
             this.gridAuthors.DataBind();
         }
         else
         {
             ShowModal("Information", "No results were found with this name.");
             this.txtData.Text = "";
         }
     }
     else
     {
         Response.Redirect("~/Account/Login.aspx");
     }
 }
Exemple #28
0
 void FormLoad()
 {
     try
     {
         double w = (double)this.Width / 12;
         this.lstShortCuts.Columns[0].Width = (int)(2 * w - 9);
         this.lstShortCuts.Columns[1].Width = (int)(7 * w - 9);
         this.lstShortCuts.Columns[2].Width = (int)(3 * w - 9);
         SQLiteManager.Execute(Crud.CreateTableQuery(), null);
         AppVariables.AllList = SQLiteManager.AllList();
         shortCutList         = AppVariables.AllList;
         Utility.List2ListView(lstShortCuts, shortCutList);
         cmbxTur.SelectedIndex = 0;
         this.lstShortCuts.AutoResizeColumns(ColumnHeaderAutoResizeStyle.None);
     }
     catch (Exception ex)
     {
         MessageUtil.Error("Program could not be started.");
         Logger.WriteException(ex, "ListFormLoad", "Program could not be loadaed.");
     }
 }
Exemple #29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Crud          crud   = new Crud();
            SqlDataReader reader = crud.getUser();

            while (reader.Read())
            {
                TableRow r = new TableRow();
                for (int i = 1; i < reader.FieldCount; i++)
                {
                    TableCell c = new TableCell();
                    c.Text = reader[i].ToString();
                    r.Cells.Add(c);
                }
                TableCell edit   = addEdit("e-" + reader[0].ToString());
                TableCell delete = addDelete("d-" + reader[0].ToString());
                r.Cells.Add(edit);
                r.Cells.Add(delete);
                Table2.Rows.Add(r);
            }
        }
 public IActionResult SaveTextCustomData(int projectId, TextProjectConfiguration textProjectConfiguration,
                                         string configurationName,
                                         Crud crudOption, string oldConfigurationName)
 {
     try
     {
         if (textProjectConfiguration.PossibleValues.Contains(null))
         {
             textProjectConfiguration.PossibleValues.Remove(null);
         }
         SaveConfiguration(projectId, textProjectConfiguration, configurationName, crudOption,
                           ConfigurationType.Text, oldConfigurationName);
         Alert(AlertType.Success, "Data saved correctly.");
         return(RedirectToAction("GetById", "Projects", new { id = projectId }));
     }
     catch (Exception ex)
     {
         Alert(AlertType.Warning, ex.Message);
         return(RedirectToAction("GetById", "Projects", new { id = projectId }));
     }
 }
Exemple #31
0
        public void Test1()
        {
            var compiler = new PostgresCompiler();
            var logger   = new ConsoleLogger(LogLevel.Debug | LogLevel.Error | LogLevel.Warning);

            using (var crud = new Crud(compiler, logger, () => { return(new NpgsqlConnection(conStr)); }))
            {
                // Assert.Throws<System.Net.Sockets.SocketException>(() =>
                // {
                //     var affectedRows = crud.Insert(new Employee()
                //     {
                //         Guid = Guid.NewGuid(),
                //         FirstName = "fist name",
                //         LastName = "last name",
                //         Active = true,
                //         CreateDate = DateTime.Now,
                //     });
                //     Assert.Equal(1, affectedRows);
                // });
            }
        }
Exemple #32
0
 public ActionResult AddPictures(AlbumViewModel Model, HttpPostedFileBase file)
 {
     if (file != null)
     {
         Thread.Sleep(1000);
         PictureViewModel PictureModel = new PictureViewModel();
         //Save file in Project
         file.SaveAs(Path.Combine(Server.MapPath("~/Pictures"), file.FileName));
         //Fill Picture Model
         PictureModel.Public     = false;
         PictureModel.Name       = file.FileName;
         PictureModel.Url        = $@"/Pictures/" + file.FileName;
         PictureModel.Size       = file.ContentLength;
         PictureModel.Id         = Guid.NewGuid();
         PictureModel.AlbumRefID = Model.Id;
         Crud.CreatePicture(PictureModel.ToEntity());
         //Spara ny bild med album ref id (skika till någon vettig plats!)
         return(Content("Picture Added!"));
     }
     return(Content("Need a(.jpg, .jpeg, .bmp, .gif, .png) file!"));
 }
Exemple #33
0
        public void LoadData()
        {
            if (dataList.Count > 0)
            {
                dataList.Clear();
            }

            var res = Crud.GetAll <Models.Core.Logging>();
            IEnumerable <Models.Core.Logging> sortedEnum = res.OrderBy(f => f.Timestamp);
            IList <Models.Core.Logging>       sortedList = sortedEnum.ToList();

            foreach (var loggingItem in sortedList)
            {
                LogWrapper log = new LogWrapper();
                log.Logging = loggingItem;

                dataList.Add(log);
            }
            dgvLog.DataSource = null;
            dgvLog.DataSource = dataList;
        }
Exemple #34
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "Book";

            if (Request.IsAuthenticated)
            {
                if (!this.IsPostBack)
                {
                    AuthorBook authorBook = Crud.GetBookByISBN(Request.QueryString["ISBN"].ToString());
                    if (authorBook != null)
                    {
                        id_author                 = authorBook.Author.Id;
                        this.txtAuthorID.Text     = authorBook.Author.Id.ToString();
                        this.txtArtisticName.Text = authorBook.Author.ArtisticName;

                        id_book            = authorBook.Book.Id;
                        this.txtTitle.Text = authorBook.Book.Title;
                        this.txtISBN.Text  = authorBook.Book.Isbn;
                        isbn_book          = authorBook.Book.Isbn;
                        this.txtPages.Text = authorBook.Book.Page.ToString();
                        this.txtPrice.Text = authorBook.Book.Price.ToString();

                        var base64 = Convert.ToBase64String(authorBook.Book.Picture);
                        var imgSrc = String.Format("data:image/gif;base64,{0}", base64);
                        this.hpCurrImage.NavigateUrl = imgSrc;

                        this.hplnkRetDet.NavigateUrl = "../../Registration/Books/Details.aspx?ISBN=" + authorBook.Book.Isbn;
                    }
                    else
                    {
                        ShowModal("Information", "No author found with this id.");
                        Response.Redirect("Authors/Search.aspx");
                    }
                }
            }
            else
            {
                Response.Redirect("~/Account/Login.aspx");
            }
        }
        public void AddContestDetail(int contest_id)
        {
            //插入数据库question表的数据
            List<CfContestDetail> list_fetch = cf.GetContestDetails(contest_id);
            int allNum = list_fetch.First().PointTime.Count;
            Crud<Detail> crud = new Crud<Detail>();
            Crud<Question> crud2 = new Crud<Question>();
            Question question = new Question();
            Detail detail = new Detail();
            foreach (var item in list_fetch)//每一个user
            {
                detail.ContestId = item.ContestId;
                detail.Username = item.UserName;
                detail.AllNum = item.PointTime.Count;

                detail.ChallengeSuccess = item.ChallengeSucceed;
                detail.ChallengeFailed = item.ChallengeFailed;
                detail.Type = "cf";

                //detail.ContestName 等待加入
                int allpoint=0;

                question.ContestId = item.ContestId;
                question.UserName = item.UserName;
                question.Type = "cf";
                int i=1;
                foreach (var pointTime in item.PointTime)//每一个user的每一题
                {
                    int point = pointTime.Item1;//point
                    question.Point = point;
                    string time = pointTime.Item2;//time
                    question.Time = Convert.ToInt32(time);//调试下
                    question.Num = i;
                    i++;
                    allpoint += point;
                }
            }
        }
 static OrderController CreateSingleService()
 {
     var crud = new Crud<Order>();
     return new OrderController(crud, crud, crud);
 }
Exemple #37
0
 public string GetRoleFromCollaborator(ajt_collaborator coll)
 {
     ICrud<aspnetuser> crud = new Crud<aspnetuser>();
     List<aspnetuser> users = crud.GetAll().ToList();
     aspnetuser user = users.Where(x => x.Id == coll.id_user_fk).FirstOrDefault();
     List<aspnetrole> liste = user.aspnetroles.ToList();
     return liste[0].Name;
 }