You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Txgy.EWS.Server.ICommon;
|
|
|
|
|
using Txgy.EWS.Server.IService;
|
|
|
|
|
using Txgy.EWS.Server.Models;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
namespace Txgy.EWS.Server.Service
|
|
|
|
|
{
|
|
|
|
|
public class FileUpgradeService : BaseService, IFileUpgradeService
|
|
|
|
|
{
|
|
|
|
|
public FileUpgradeService(IDbConnectionFactory contextFactor) : base(contextFactor)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int AddOrUpdate(UpgradeFile upgradeFile)
|
|
|
|
|
{
|
|
|
|
|
var query = (from q in Context.Set<UpgradeFile>()
|
|
|
|
|
where q.FileName == upgradeFile.FileName
|
|
|
|
|
select q.FileId).ToList();
|
|
|
|
|
|
|
|
|
|
var entity = Context.Entry(upgradeFile);
|
|
|
|
|
if (query.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
upgradeFile.FileId = query[0];
|
|
|
|
|
entity.State = EntityState.Modified;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
entity.State = EntityState.Added;
|
|
|
|
|
}
|
|
|
|
|
return Context.SaveChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|