本文整理汇总了C#中SidejobModel.SidejobEntities.AddToClosedProjects方法的典型用法代码示例。如果您正苦于以下问题:C# SidejobEntities.AddToClosedProjects方法的具体用法?C# SidejobEntities.AddToClosedProjects怎么用?C# SidejobEntities.AddToClosedProjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SidejobModel.SidejobEntities
的用法示例。
在下文中一共展示了SidejobEntities.AddToClosedProjects方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddToClosedProject
public void AddToClosedProject(int projectId)
{
int bidderid = 0;
using (var context = new SidejobEntities())
{
var cp = (from c in context.ClosedProjects
where c.ProjectID == projectId
select c).FirstOrDefault();
if (cp != null)
{
var bidder = (from p in context.Projects
where p.ProjectID == projectId
select p).FirstOrDefault();
if (bidder != null)
{
if (bidder.HighestBidderID != null)
{
bidderid = (int)bidder.HighestBidderID;
}
}
var newclosedproject = from p in context.Projects
join b in context.Bids
on p.ProjectID equals b.ProjectID
where p.ProjectID == projectId &&
b.BidderID == bidderid
select new ClosedProject
{
ProjectID = projectId,
DateFinished = DateTime.Now.Date,
PosterID = p.PosterID,
PosterRole = p.PosterRole,
BidderID = p.HighestBidderID,
BidderRole = b.BidderRole,
HighestBid = p.HighestBid,
CurrencyID = b.CurrencyID,
Status = 3
};
context.AddToClosedProjects((ClosedProject)newclosedproject);
context.SaveChanges();
GetBidderPosterProjectProperties(projectId, 0, (ClosedProject)newclosedproject);
}
}
}
示例2: AddToClosedProject
/////////////////////ADD TO CLOSED PROJECT/////////////////////////
public void AddToClosedProject(int projectId)
{
int bidderid = 0;
using (var context = new SidejobEntities())
{
var cp = (from c in context.ClosedProjects
where c.ProjectID == projectId
select c).FirstOrDefault();
if (cp == null)
{
var bidder = (from p in context.Projects
where p.ProjectID == projectId
select p).FirstOrDefault();
if (bidder != null)
{
if (bidder.HighestBidderID != null)
{
bidderid = (int)bidder.HighestBidderID;
}
}
var chosenproject = (from p in context.Projects
where p.ProjectID == projectId
select p).FirstOrDefault();
var chosenbid = (from p in context.Bids
where p.BidderID == bidderid
select p).FirstOrDefault();
if (chosenproject != null && chosenbid != null)
{
var newcp = new ClosedProject
{
ProjectID = projectId,
DateFinished = DateTime.UtcNow.Date,
PosterID = chosenproject.PosterID,
PosterRole = chosenproject.PosterRole,
BidderID = chosenproject.HighestBidderID,
BidderRole = chosenbid.BidderRole,
HighestBid = chosenproject.HighestBid,
CurrencyID = chosenbid.CurrencyID,
Status = 3
};
context.AddToClosedProjects(newcp);
context.SaveChanges();
GetBidderPosterProjectProperties(projectId, 0, newcp);
}
}
}
}