Когда я пытаюсь скомпилировать, я получаю следующую ошибку. Надеюсь, я пропустил что-то простое.
Ошибка CS0535: 'CMTaskPriorityRepository' не реализует член интерфейса 'ICMTaskPriorityRepository.GetAllCMTaskPriority ()
CMTaskPriorityRepository.cs
public class CMTaskPriorityRepository : ICMTaskPriorityRepository
{
private readonly AppDbContext _appDbContext;
public CMTaskPriorityRepository(AppDbContext appDbContext)
{
_appDbContext = appDbContext;
}
public IEnumerable<CMTaskPriority> GetAllCMTaskPrioritys()
{
return _appDbContext.CMTaskPriority;
}
public IEnumerable<CMTaskPriority> GetCMTaskPrioritys()
{
return _appDbContext.CMTaskPriority;
}
public CMTaskPriority GetCMTaskPriorityById(int cmtaskpriorityid)
{
return _appDbContext.CMTaskPriority.FirstOrDefault(c => c.TaskPriorityID == cmtaskpriorityid);
}
public CMTaskPriority CreateCMTaskPriority(CMTaskPriority cmtaskpriority)
{
var addedEntity = _appDbContext.CMTaskPriority.Add(cmtaskpriority);
_appDbContext.SaveChanges();
return addedEntity.Entity;
}
CMTaskPriority ICMTaskPriorityRepository.UpdateCMTaskPriority(CMTaskPriority cmtaskpriority)
{
var foundCMTaskPriority = _appDbContext.CMTaskPriority.FirstOrDefault(e => e.TaskPriorityID == cmtaskpriority.TaskPriorityID);
if (foundCMTaskPriority != null)
{
foundCMTaskPriority.TaskPriorityID = cmtaskpriority.TaskPriorityID;
foundCMTaskPriority.PriorityLevel = cmtaskpriority.PriorityLevel;
foundCMTaskPriority.DisplayOrder = cmtaskpriority.DisplayOrder;
foundCMTaskPriority.IsDeletd = cmtaskpriority.IsDeletd;
_appDbContext.SaveChanges();
return foundCMTaskPriority;
}
return null;
}
}
}
* 1007 ICMTaskPriorityRepository.cs
public interface ICMTaskPriorityRepository
{
IEnumerable<CMTaskPriority> GetAllCMTaskPriority();
CMTaskPriority GetCMTaskPriorityById(int CMTaskPriorityID);
CMTaskPriority UpdateCMTaskPriority(CMTaskPriority cmtaskpriority);
CMTaskPriority CreateCMTaskPriority(CMTaskPriority cmtaskpriority);
}
CMTaskPriorityController.cs
[ApiController]
[Route("[controller]")]
public class CMTaskPriorityController : ControllerBase
{
private readonly ICMTaskPriorityRepository _CMTaskPriorityRepository;
public CMTaskPriorityController(ICMTaskPriorityRepository CMTaskPriorityRepository)
{
_CMTaskPriorityRepository = CMTaskPriorityRepository;
}
[HttpGet]
public IActionResult GetCMTaskPriority()
{
return Ok(_CMTaskPriorityRepository.GetAllCMTaskPriority());
}
[HttpGet("{TaskPriorityID}")]
public IActionResult GetTaskPriorityByID(int id)
{
return Ok(_CMTaskPriorityRepository.GetCMTaskPriorityById(id));
}
[HttpPost]
public IActionResult CreateCMTaskPriority([FromBody] CMTaskPriority cmtaskpriority)
{
if (cmtaskpriority == null)
return BadRequest();
if (cmtaskpriority.PriorityLevel == string.Empty || cmtaskpriority.PriorityLevel == string.Empty)
{
ModelState.AddModelError("Priority/Level", "The priority level shouldn't be empty");
}
if (!ModelState.IsValid)
return BadRequest(ModelState);
var createdCMTaskPriority = _CMTaskPriorityRepository.CreateCMTaskPriority(cmtaskpriority);
return Created("cmtaskpriority", createdCMTaskPriority);
}
[HttpPut]
public IActionResult UpdateCMTaskPriority([FromBody] CMTaskPriority cmtaskpriority)
{
if (cmtaskpriority == null)
return BadRequest();
if (cmtaskpriority.PriorityLevel == string.Empty || cmtaskpriority.PriorityLevel == string.Empty)
{
ModelState.AddModelError("Priority/Level", "The priority level shouldn't be empty");
}
if (!ModelState.IsValid)
return BadRequest(ModelState);
var CMTaskPriorityToUpdate = _CMTaskPriorityRepository.GetCMTaskPriorityById(cmtaskpriority.TaskPriorityID);
if (CMTaskPriorityToUpdate == null)
return NotFound();
_CMTaskPriorityRepository.UpdateCMTaskPriority(cmtaskpriority);
return NoContent(); //success
}
}
}