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;
 }
Пример #4
0
        public IStatusGeneric UpdateProject(string wbsCode, WfCalculationType calType)
        {
            var status = new StatusGenericHandler();

            //All Ok
            this.WBSCode         = wbsCode;
            this.CalculationType = calType;

            return(status);
        }
Пример #5
0
        public IStatusGeneric UpdateMDRDocument(string title, string description, long mdrDocId)
        {
            var pstatus = new StatusGenericHandler();

            this.Title         = title;
            this.Description   = description;
            this.MDRDocumentId = mdrDocId;

            return(pstatus);
        }
Пример #6
0
            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);
        }
Пример #8
0
        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");
        }
Пример #10
0
        public void TestGenericStatusGenericOk()
        {
            //SETUP

            //ATTEMPT
            var status = new StatusGenericHandler <string>();

            //VERIFY
            status.IsValid.ShouldBeTrue();
            status.Result.ShouldEqual(null);
        }
Пример #11
0
        public void TestStatusIsValidWithClassResultOk()
        {
            //SETUP
            var status = new StatusGenericHandler();

            //ATTEMPT
            var actionResult = status.Response <string>("Hello");

            //VERIFY
            actionResult.CheckResponse(status, "Hello");
        }
Пример #12
0
        public static IStatusGeneric <LocationType> CreateLocationType(string title)
        {
            var status   = new StatusGenericHandler <LocationType>();
            var location = new LocationType
            {
                Title = title
            };

            status.Result = location;
            return(status);
        }
Пример #13
0
        public void TestStatusIsValidWithResultOk()
        {
            //SETUP
            var status = new StatusGenericHandler();

            //ATTEMPT
            var actionResult = status.Response(1);

            //VERIFY
            actionResult.CheckResponse(status, 1);
        }
Пример #14
0
        public void TestStatusIsValidWithClassResultNullAndStatusCodeOk()
        {
            //SETUP
            var status = new StatusGenericHandler();

            //ATTEMPT
            var actionResult = status.ResponseWithValidCode <string>(null, CreateResponse.OkStatusCode);

            //VERIFY
            actionResult.CheckResponse(status, null);
        }
Пример #15
0
        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);
        }
Пример #16
0
        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);
        }
Пример #20
0
        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);
        }
Пример #21
0
        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;
 }
Пример #23
0
        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);
        }
Пример #24
0
        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");
        }
Пример #26
0
        public void TestStatusErrorWithClassResultNullOk()
        {
            //SETUP
            var status = new StatusGenericHandler();

            status.AddError("Bad");

            //ATTEMPT
            var actionResult = status.Response <string>(null);

            //VERIFY
            actionResult.CheckResponse(status, null);
        }
Пример #27
0
        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");
        }
Пример #29
0
        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);
        }