static Bulletin AddAvitoByTemplate(Guid userId, BulletinTemplate template, string brand, string model, string modifier, string price, string groupHash) { var result = default(Bulletin); BCT.Execute(d => { var group = BCT.Context.BulletinDb.Groups.FirstOrDefault(q => q.Hash == groupHash); if (group == null) { ConsoleHelper.SendMessage($"AvitoPublicateBulletin => Группа с хэшем:{groupHash} не найдена"); return; } result = new Bulletin(); result.Brand = brand; result.Model = model; result.Modifier = modifier; result.GroupId = group.Id; result.Title = template.Title; result.Description = template.Description; result.Price = price; result.Images = template.Images; result.UserId = userId; result.StateEnum = BulletinState.Created; d.SaveChanges(); }); return(result); }
public static BulletinTemplate MarkAsUsed(BulletinTemplate template) { BCT.Execute(c => { template.StateEnum = DefaultState.Disable; c.SaveChanges(); }); return(template); }