本文整理匯總了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);
}
}
}
}