Files
LaDOSE/LaDOSE.Src/LaDOSE.Service/Service/TodoService.cs
Darkstack b8d49cea69 Todo : Fix format
RestService : Fix connection if first connection fail
BL : Fix Update/Delete return value
2019-03-28 00:23:44 +01:00

43 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using LaDOSE.Business.Interface;
using LaDOSE.Entity;
using LaDOSE.Entity.Context;
using Microsoft.EntityFrameworkCore;
namespace LaDOSE.Business.Service
{
public class TodoService : BaseService<Todo>, ITodoService
{
public TodoService(LaDOSEDbContext context) : base(context)
{
}
public override bool Delete(int id)
{
try
{
var find = _context.Find<Todo>(id);
if (find != null)
{
if (find.Deleted.HasValue)
return false;
find.Deleted = DateTime.Now;
}
this._context.SaveChanges();
return true;
}
catch (DbUpdateException)
{
return false;
}
}
public override IEnumerable<Todo> GetAll()
{
return _context.Set<Todo>().Where(e=>e.Deleted == null).ToList();
}
}
}