private Task <IStatusGeneric> DelHandlerAsync(DbContext context, SoftDelEntity entity) { var status = new StatusGenericHandler(); if (!entity.SoftDeleted) { status.AddError("Can't delete if not already soft deleted."); } return(Task.FromResult((IStatusGeneric)status)); }
private async Task <IStatusGeneric> DeleteCheck(DbContext db, Book entity) { var status = new StatusGenericHandler(); if (entity.BookId == 1) { status.AddError("Stop delete"); } return(await Task.FromResult(status)); }
public LoginService(UserManager <ApplicationUser> userManager, IJwtFactory jwtFactory, IErrorFactory errorFactory, ApplicationDbContext context, IRetrieveAuthenticatedUserService retrieveAuthenticatedUserService) { Status = new StatusGenericHandler(); _userManager = userManager; _jwtFactory = jwtFactory; _errorFactory = errorFactory; _context = context; _retrieveAuthenticatedUserService = retrieveAuthenticatedUserService; }
public IStatusGeneric UpdateProject(string wbsCode, WfCalculationType calType) { var status = new StatusGenericHandler(); //All Ok this.WBSCode = wbsCode; this.CalculationType = calType; return(status); }
public IStatusGeneric UpdateMDRDocument(string title, string description, long mdrDocId) { var pstatus = new StatusGenericHandler(); this.Title = title; this.Description = description; this.MDRDocumentId = mdrDocId; return(pstatus); }
public static IStatusGeneric <Target1> Create(int myInt, string myString) { var status = new StatusGenericHandler <Target1> { Message = "Static" }; return(status.SetResult(new Target1(myInt, myString))); }
private IStatusGeneric CheckIfInOrder(DbContext context, Book entityToDelete) { var status = new StatusGenericHandler(); //In this case the check stops an exception caused by the "DeleteBehavior.Restrict" on the BookId in the LineItem entity class if (context.Set <LineItem>().Any(x => x.BookId == entityToDelete.BookId)) { status.AddError("I'm sorry, but I can't delete that book because it is in a customer's order."); } return(status); }
public static IStatusGeneric <WorkPackage> CreateRoadMap(string name) { var status = new StatusGenericHandler <WorkPackage>(); var newRoadMap = new WorkPackage { Name = name, }; status.Result = newRoadMap; return(status); }
public void TestBaseStatus() { //SETUP //ATTEMPT var status = new StatusGenericHandler(); //VERIFY status.HasErrors.ShouldBeFalse(); status.Message.ShouldEqual("Success"); }
public void TestGenericStatusGenericOk() { //SETUP //ATTEMPT var status = new StatusGenericHandler <string>(); //VERIFY status.IsValid.ShouldBeTrue(); status.Result.ShouldEqual(null); }
public void TestStatusIsValidWithClassResultOk() { //SETUP var status = new StatusGenericHandler(); //ATTEMPT var actionResult = status.Response <string>("Hello"); //VERIFY actionResult.CheckResponse(status, "Hello"); }
public static IStatusGeneric <LocationType> CreateLocationType(string title) { var status = new StatusGenericHandler <LocationType>(); var location = new LocationType { Title = title }; status.Result = location; return(status); }
public void TestStatusIsValidWithResultOk() { //SETUP var status = new StatusGenericHandler(); //ATTEMPT var actionResult = status.Response(1); //VERIFY actionResult.CheckResponse(status, 1); }
public void TestStatusIsValidWithClassResultNullAndStatusCodeOk() { //SETUP var status = new StatusGenericHandler(); //ATTEMPT var actionResult = status.ResponseWithValidCode <string>(null, CreateResponse.OkStatusCode); //VERIFY actionResult.CheckResponse(status, null); }
public IStatusGeneric SetString(string myString) { var status = new StatusGenericHandler(); if (myString == null) { return(status.AddError("The string should not be null.")); } MyString = myString; return(status); }
public static IStatusGeneric <Descipline> CreateDesciplineFactory(string name, string description, Guid[] projectIds) { var status = new StatusGenericHandler <Descipline>(); var descipline = new Descipline { Description = description, Name = name }; status.Result = descipline; return(status); }
public void TestGenericStatusHeaderAndErrorOk() { //SETUP var status = new StatusGenericHandler("MyClass"); //ATTEMPT status.AddError("This is an error."); //VERIFY status.IsValid.ShouldBeFalse(); status.Errors.Single().ToString().ShouldEqual("MyClass: This is an error."); }
public void TestGenericStatusOk() { //SETUP //ATTEMPT var status = new StatusGenericHandler(); //VERIFY status.IsValid.ShouldBeTrue(); status.Errors.Any().ShouldBeFalse(); status.Message.ShouldEqual(StatusGenericHandler.DefaultSuccessMessage); }
public void TestStatusIsValidWithStatusCodeOk() { //SETUP var status = new StatusGenericHandler(); var actionResult = status.ResponseWithValidCode(201); //ATTEMPT var statusCode = actionResult.GetStatusCode(); //VERIFY statusCode.ShouldEqual(201); }
public IStatusGeneric ChangeName(string name) { var status = new StatusGenericHandler(); if (name.EndsWith("!")) { status.AddError("Business logic says the name canot end with !", nameof(Name)); } Name = name; return(status); }
public static IStatusGeneric <PunchCategory> CreatePunchCategory(string name, Guid projectId) { var status = new StatusGenericHandler <PunchCategory>(); var punchType = new PunchCategory { Name = name, ProjectId = projectId }; status.Result = punchType; return(status); }
public RegisterAccountService(UserManager <ApplicationUser> userManager, ApplicationDbContext context, IErrorFactory errorFactory, IMapper mapper, ISendEmailService sendEmailService, IGenerateAccountEmailsService confirmationEmailService) { Status = new StatusGenericHandler(); _userManager = userManager; _context = context; _errorFactory = errorFactory; _mapper = mapper; _sendEmailService = sendEmailService; _confimationEmailService = confirmationEmailService; }
public IStatusGeneric UpdateMDRDocument(string title, string description, int WorkPackageId, string code, MDRDocumentType type) { var pstatus = new StatusGenericHandler(); this.Title = title; this.Description = description; this.WorkPackageId = WorkPackageId; this.Code = code; this.Type = type; return(pstatus); }
public void TestStatusHasErrorOk() { //SETUP var status = new StatusGenericHandler(); status.AddError("An Error", "MyProp"); //ATTEMPT var actionResult = status.Response(); //VERIFY actionResult.CheckResponse(status); }
public void TestGenericStatusWithErrorOk() { //SETUP var status = new StatusGenericHandler(); //ATTEMPT status.AddError("This is an error."); //VERIFY status.IsValid.ShouldBeFalse(); status.Errors.Single().ToString().ShouldEqual("This is an error."); status.Message.ShouldEqual("Failed with 1 error"); }
public void TestStatusErrorWithClassResultNullOk() { //SETUP var status = new StatusGenericHandler(); status.AddError("Bad"); //ATTEMPT var actionResult = status.Response <string>(null); //VERIFY actionResult.CheckResponse(status, null); }
public void TestStatusErrorWithResultOk() { //SETUP var status = new StatusGenericHandler(); status.AddError("Bad"); //ATTEMPT var actionResult = status.Response(1); //VERIFY actionResult.CheckResponse(status, 1); }
public void TestStatusHasOneErrors() { //SETUP var status = new StatusGenericHandler(); //ATTEMPT status.AddError("This is an error"); //VERIFY status.HasErrors.ShouldBeTrue(); status.Message.ShouldEqual("Failed with 1 error"); status.GetAllErrors().ShouldEqual("This is an error"); }
public static IStatusGeneric <RoleToPermissions> CreateRoleWithPermissions(string roleName, string description, ICollection <Permissions> permissionInRole, ExtraAuthorizeDbContext context) { var status = new StatusGenericHandler <RoleToPermissions>(); if (context.Find <RoleToPermissions>(roleName) != null) { status.AddError("That role already exists"); return(status); } return(status.SetResult(new RoleToPermissions(roleName, description, permissionInRole))); }
public static IStatusGeneric <FormDictionaryDescipline> CreateFormDicDescipline(long formDicId, int desciplineId) { var status = new StatusGenericHandler <FormDictionaryDescipline>(); var newItem = new FormDictionaryDescipline { DesciplineId = desciplineId, FormDictionaryId = formDicId }; status.Result = newItem; return(status); }