public async Task <ApiResponse <ChecklistType> > CreateChecklistType(ChecklistTypeDto checklistTypeDto) { var response = new ApiResponse <ChecklistType>(); try { //check videotype Exists var isExistChecklistType = await _checklistTypeRepository.CountAsync(i => i.Name == checklistTypeDto.Name); if (isExistChecklistType != 0) { response.Success = false; response.Errors.Add("ChecklistType Already Exists"); return(response); } var id = Guid.NewGuid(); //create new videotype var checklistType = Mapper.Map <ChecklistType>(checklistTypeDto); checklistType.Id = id; checklistType.CreatedDate = DateTime.Now; checklistType.IsActive = true; await _checklistTypeRepository.AddAsyn(checklistType); response.Success = true; } catch (Exception ex) { response.Success = false; response.Errors.Add(ex.Message); } return(response); }
public async Task <ApiResponse <ChecklistType> > CreateChecklistType(ChecklistTypeDto course) { try { return(await _checklisttypeServices.CreateChecklistType(course)); } catch (Exception ex) { return(new ApiResponse <ChecklistType>() { Success = false, Errors = new List <string>() { ex.Message } }); } }