public void OnRate() { if (RatingHasError()) { return; } Subject subjectToRate = teacher.subjects[subjectDropdown.value]; string ratings = ""; for (int i = 0; i < itemList.Count; i++) { ratings += i != itemList.Count - 1 ? itemList[i].Rating + ";" : itemList[i].Rating.ToString(); } DbComment dbcomment = new DbComment() { id = Guid.NewGuid().ToString(), description = commentInput.text, subjectId = subjectToRate.id, studentId = Core.UserManager.Instance.CurrentUser.id, teacherId = teacher.id, skillRatings = ratings, timeStamp = DateTime.UtcNow.Ticks }; FirebaseManager.Instance.PushToCloud <DbComment>(dbcomment, RateSuccess); _repo.AddDbModel <Comment>(dbcomment); }
private void fill_comments() { comments_list = DbComment.get_comments_of_active_user(); try { panel_comment0.Visible = true; lbl_product0_name.Text = comments_list[list_index - 1].GetProduct().GetName(); lbl_sellername0.Text = comments_list[list_index - 1].GetProduct().GetOwner().GetName(); rtxtb_comment0.Text = comments_list[list_index - 1].GetText(); picturebox_product0.ImageLocation = comments_list[list_index - 1].GetProduct().GetImage(); } catch (Exception) { panel_comment0.Visible = false; } try { panel_comment1.Visible = true; lbl_product1_name.Text = comments_list[list_index].GetProduct().GetName(); lbl_sellername1.Text = comments_list[list_index].GetProduct().GetOwner().GetName(); rtxtb_comment1.Text = comments_list[list_index].GetText(); picturebox_product1.ImageLocation = comments_list[list_index].GetProduct().GetImage(); } catch (Exception) { lbl_product1_name.Text = ""; lbl_sellername1.Text = ""; rtxtb_comment1.Text = ""; panel_comment1.Visible = false; } }
public async void RemoveComment(long idComment) { DbComment comment = await db.Conn.Table <DbComment>().Where(c => c.Id == idComment).FirstOrDefaultAsync(); if (comment != null) { await db.Conn.DeleteAsync(comment); } }
private void fill_comments() { try { comments_list = DbComment.comments_of_product(Convert.ToInt32(dataGridView_productsOfSeller.CurrentRow.Cells["ProductId"].Value)); panel_comment0.Visible = true; panel_comment1.Visible = true; try { lbl_comment0_text.Text = comments_list[comment_list_index - 1].GetText(); lbl_comment0_createDate.Text = comments_list[comment_list_index - 1].GetCreateTime().ToString(); if (comments_list[comment_list_index - 1].GetSeller().GetId() != 0) { picturebox_comment0_userimage.ImageLocation = comments_list[comment_list_index - 1].GetSeller().GetImage(); lbl_comment0_username.Text = comments_list[comment_list_index - 1].GetSeller().GetName(); } else { picturebox_comment0_userimage.ImageLocation = comments_list[comment_list_index - 1].GetCustomer().GetImage(); lbl_comment0_username.Text = comments_list[comment_list_index - 1].GetCustomer().GetName(); } } catch (Exception) { panel_comment0.Visible = false; } try { lbl_comment1_text.Text = comments_list[comment_list_index].GetText(); lbl_comment1_createDate.Text = comments_list[comment_list_index].GetCreateTime().ToString(); if (comments_list[comment_list_index].GetSeller().GetId() != 0) { picturebox_comment1_userimage.ImageLocation = comments_list[comment_list_index].GetSeller().GetImage(); lbl_comment1_username.Text = comments_list[comment_list_index].GetSeller().GetName(); } else { picturebox_comment1_userimage.ImageLocation = comments_list[comment_list_index].GetCustomer().GetImage(); lbl_comment1_username.Text = comments_list[comment_list_index].GetCustomer().GetName(); } } catch (Exception) { panel_comment1.Visible = false; } } catch (Exception) // bir şekilde boş dgv ye tıklarsa sorun çıkarmasın { } }
public static Comment ToExposed(this DbComment comment) { return(new Comment { Id = comment.Id, IdCreator = comment.IdCreator, IdImage = comment.IdImage, Message = comment.Message, Creator = comment.Creator == null ? null : comment.Creator.ToExposed(), Image = comment.Image == null ? null : comment.Image.ToExposed() }); }
private void btn_addComment_Click(object sender, EventArgs e) { Comment comment = new Comment(); comment.SetText(richTxtb_commentText.Text); comment.SetCreateTime(DateTime.Now); comment.SetProduct(this.product); comment.SetCustomer(DbCustomer.get_customer_from_id(Customer.activeCustomer)); comment.SetSeller(DbSeller.get_seller_data_from_id(Seller.activeSeller)); DbComment.add_comment(comment); }
public override void LoadModel(DbBase entity) { skillRatings = new Dictionary <Skill, int>(); DbComment comment = entity as DbComment; this.id = comment.id; this.studentId = comment.studentId; this.teacherId = comment.teacherId; this.subjectId = comment.subjectId; this.description = comment.description; this.skillRatingIds = comment.skillRatings; this.timeStamp = comment.timeStamp; }
private void fill_comments() { comments_list = DbComment.comments_of_product(product.GetId()); lbl_comment0_username.ForeColor = Color.Black; lbl_comment1_username.ForeColor = Color.Black; try { //1. yorum paneli if (comments_list[list_index - 1].GetSeller().GetId() != 0) //satıcı yorumu ise satıcının adını renkli bastırıcak { lbl_comment0_username.Text = comments_list[list_index - 1].GetSeller().GetName(); lbl_comment0_username.ForeColor = Color.Salmon; lbl_comment0_text.Text = comments_list[list_index - 1].GetText(); } if (comments_list[list_index - 1].GetCustomer().GetId() != 0) { lbl_comment0_username.Text = comments_list[list_index - 1].GetCustomer().GetName(); lbl_comment0_username.ForeColor = Color.Black; lbl_comment0_text.Text = comments_list[list_index - 1].GetText(); } } catch (Exception) { lbl_comment0_username.Text = ""; lbl_comment0_text.Text = ""; } try { //2. yorum paneli if (comments_list[list_index].GetSeller().GetId() != 0) { lbl_comment1_username.Text = comments_list[list_index].GetSeller().GetName(); lbl_comment1_username.ForeColor = Color.Salmon; lbl_comment1_text.Text = comments_list[list_index].GetText(); } if (comments_list[list_index].GetCustomer().GetId() != 0) { lbl_comment1_username.Text = comments_list[list_index].GetCustomer().GetName(); lbl_comment1_username.ForeColor = Color.Black; lbl_comment1_text.Text = comments_list[list_index].GetText(); } } catch (Exception) { lbl_comment1_username.Text = ""; lbl_comment1_text.Text = ""; } }
public async Task <long> AddComment(String vat, String comment) { long id = 0; DateTime date = DateTime.Now; DbComment dbc = new DbComment(vat, comment, date); await db.Conn.InsertAsync(dbc); DbComment insertDbc = await db.Conn.Table <DbComment>().ElementAtAsync(await db.Conn.Table <DbComment>().CountAsync() - 1); if (insertDbc != null) { id = insertDbc.Id; } return(id); }
public async Task CreateOrReplace(WarehouseCreateMode mode, [CanBeNull] string schema, ILogger log) { if (mode == CloneProd && Sf.Cfg.DbSuffix.NullOrEmpty()) { throw new( "DbSuffix needs to be set when cloning a db. Typically you should set warehouse.mode to \"Branch\" in local.appcfg.json to create a dev warehouse"); } var sw = Stopwatch.StartNew(); schema ??= Sf.Cfg.Schema; var stages = new[] { DbStage, Private }.Select(type => { var store = Stores.Store(type); var container = ((AzureBlobFileStore)store).Container; var sasUri = container.GenerateSasUri(List | Read, DateTimeOffset.UtcNow.AddYears(100)); var name = type switch { Private => "yt_private", DbStage => "yt_data", _ => throw new($"store type {type} has no stage") }; return(new { Uri = $"azure://{sasUri.Host}{sasUri.AbsolutePath}", Sas = sasUri.Query, Name = name }); }).ToArray(); if (mode == CreateSchemaIfNotExists) { using var dbConn = await Sf.Open(log, schema : ""); var schemaExists = await dbConn.ExecuteScalar <bool>($"{Scope} - schema exits", $"select exists(select * from information_schema.schemata where catalog_name = current_database() and schema_name ilike '{schema}')"); if (schemaExists) { return; } } // use a non-contextual connection for creating databases/schema's using var conn = await Sf.Open(log, "", ""); var db = Sf.Cfg.DbName(); var dbComment = new DbComment { Expires = DateTime.UtcNow.AddDays(2), Email = EnvCfg.Email }.ToJson(JCfg); var scripts = (mode.In(CloneProd) ? new[] { new Script("db copy", @$ "create or replace database {db} clone {Sf.Cfg.Db} comment='{dbComment}'") } : new[] { new Script("db create", @$ "create database if not exists {db} comment='{dbComment}'"), // don't replace new Script("schema", $"create schema if not exists {db}.{schema}") }) .Concat(new Script("file formats", $"create or replace file format {db}.{schema}.json type = 'json'", $"create or replace file format {db}.{schema}.json_zst type = 'json' compression = ZSTD", $"create or replace file format {db}.{schema}.tsv type = 'csv' field_delimiter = '\t' validate_UTF8 = false NULL_IF=('')", $"create or replace file format {db}.{schema}.tsv_header type = 'csv' field_delimiter = '\t' validate_UTF8 = false NULL_IF=('') skip_header=1 field_optionally_enclosed_by ='\"'", $"create or replace file format {db}.{schema}.tsv_header_no_enclose type = 'csv' field_delimiter = '\t' validate_UTF8 = false NULL_IF=('') skip_header=1")) .Concat(stages.Select(s => new Script($"stage {s.Name}", $"create or replace stage {db}.{schema}.{s.Name} url='{s.Uri}' credentials=(azure_sas_token='{s.Sas}') file_format=(type=json compression=gzip)" ))) .Concat(WhCfg.AdminRoles.Select(r => new Script($"init role {r}", ScriptMode.Parallel, $"grant all on database {db} to role {r}", $"grant all on schema {db}.{schema} to role {r}", $"grant all on all tables in schema {db}.{schema} to role {r}", $"grant all on future tables in schema {db}.{schema} to role {r}", $"grant all on all views in schema {db}.{schema} to role {r}", $"grant all on future views in schema {db}.{schema} to role {r}", $"grant all on all stages in database {db} to role {r}", $"grant all on all functions in database {db} to role {r}" ))) .Concat(WhCfg.ReadRoles.Select(r => new Script($"init role {r}", ScriptMode.Parallel, $"grant usage,monitor on database {db} to role {r}", $"grant usage, monitor on all schemas in database {db} to role {r}", $"grant select on future tables in schema {db}.{schema} to role {r}", $"grant select on future views in schema {db}.{schema} to role {r}", $"grant select on all tables in schema {db}.{schema} to role {r}", $"grant select on all views in schema {db}.{schema} to role {r}", $"grant usage on all stages in schema {db}.{schema} to role {r}", $"grant usage on all functions in schema {db}.{schema} to role {r}", $"grant usage on all file formats in schema {db}.{schema} to role {r}" ))); foreach (var s in scripts) { await s.Sqls.BlockDo <string>(q => conn.Execute(s.Name, q), s.Mode == Sequential? 1 : WhCfg.MetadataParallel); } log.Information("Create Warehouse - {Db} created/updated in {Duration}", db, sw.Elapsed.HumanizeShort()); }
public void UpdateComment(DbComment comment) { _commentRepository.Update(comment); _unitOfWork.Commit(); }
public void CreateComment(DbComment comment) { _commentRepository.Add(comment); _unitOfWork.Commit(); }