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.
88 lines
2.1 KiB
C#
88 lines
2.1 KiB
C#
using Admin.Core.IRepository;
|
|
using Admin.Core.Service;
|
|
using Admin.Core.IService;
|
|
using Admin.Core.Model;
|
|
using System.Threading.Tasks;
|
|
using System.Collections.Generic;
|
|
using System;
|
|
using Serilog;
|
|
using NPOI.SS.Formula.Functions;
|
|
using System.Linq;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Admin.Core.Service
|
|
{
|
|
public class xl_recipeServices : BaseServices<xl_recipe>, Ixl_recipeServices
|
|
{
|
|
private readonly IBaseRepository<xl_recipe> _dal;
|
|
public xl_recipeServices(IBaseRepository<xl_recipe> dal)
|
|
{
|
|
this._dal = dal;
|
|
base.BaseDal = dal;
|
|
}
|
|
|
|
public async Task<List<xl_recipe>> xlGetAllRecipes()
|
|
{
|
|
try
|
|
{
|
|
return await _dal.QueryAsync();
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<bool> xlInsertRecipe(xl_recipe recipe)
|
|
{
|
|
try
|
|
{
|
|
if(await _dal.AddAsync(recipe) == 1)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<bool> xlUpdateRecipe(xl_recipe recipe)
|
|
{
|
|
try
|
|
{
|
|
return await _dal.UpdateAsync(recipe);
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task<bool> xlUpdateOrAdd(xl_recipe recipe)
|
|
{
|
|
try
|
|
{
|
|
var record = await _dal.QueryAsync(x => x.Recipe_Code == recipe.Recipe_Code);
|
|
if(record == null || record.Count == 0)
|
|
{
|
|
recipe.ID = record[0].ID;
|
|
return await xlUpdateRecipe(recipe);
|
|
}
|
|
else
|
|
{
|
|
return await xlInsertRecipe(recipe);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
} |