Exemplo n.º 1
0
 public PoolController(CustomizationOption customizationOptions, MinerContext dbContext, PlotService plotService, PlotterService plotterService)
 {
     CustomizationOptions = customizationOptions;
     DbContext            = dbContext;
     PlotService          = plotService;
     PlotterService       = plotterService;
 }
Exemplo n.º 2
0
 public MinerController(MinerContext dbContext, FirewallService firewallService, PlotService plotService, PlotterService plotterService)
 {
     DbContext       = dbContext;
     FirewallService = firewallService;
     PlotService     = plotService;
     PlotterService  = plotterService;
 }
Exemplo n.º 3
0
 public BasicAuthHandler(IOptionsMonitor <BasicAuthOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock,
                         MinerContext dbContext, HashingService hashingService)
     : base(options, logger, encoder, clock)
 {
     DbContext      = dbContext;
     HashingService = hashingService;
 }
Exemplo n.º 4
0
 public UserController(MinerContext dbContext, HashingService hashingService, CustomizationOption customizationOptions, UserService userService)
 {
     DbContext            = dbContext;
     HashingService       = hashingService;
     CustomizationOptions = customizationOptions;
     UserService          = userService;
 }
Exemplo n.º 5
0
 public HttpResponseMessage getEmployeeOfId(int id)
 {
     if (id <= 0) {
         //invalid id for employee to be searched
         return Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ArgumentException(String.Format(
             "Cannot find employee of the id: {0}", id)));
     }
     using (MinerContext db = new MinerContext()) {
         var emp = db.Employees.Where(x => x.Id == id).FirstOrDefault();
         if (emp == null) {
             return Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ArgumentException(String.Format(
             "Cannot find employee of the id: {0}", id)));
         }
         Reportee rep = Mapping.ToWeb<Employee, Reportee>(emp);
         if (rep ==null) {
             return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, new InvalidCastException("something went wrong on the server"));
         }
         return Request.CreateResponse(HttpStatusCode.OK, rep);
     }
 }
Exemplo n.º 6
0
        public HttpResponseMessage getReporteesOfMgr(int id)
        {
            List<Reportee> result = new List<Reportee>();
            using (MinerContext db = new MinerContext()) {
                var manager = db.Managers.Where(x => x.Id == id).FirstOrDefault();
                if (manager ==null) {
                    return Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ArgumentException(String.Format(
                        "manager of the id : {0} not found ", id)));
                }
                Array.ForEach(manager.Reportees.ToArray(), r => {
                    Reportee rep = Mapping.ToWeb<Employee, Reportee>(r);
                    if (rep!=null) {
                        rep.skillcount = db.SkillMaps.Where(x=>x.Employee.Id==rep.id).Count();
                        rep.updatedskills = db.SkillMaps.Where(x => x.Employee.Id == rep.id && x.Level.Level!=0).Count();
                    }
                    result.Add(rep);
                });
            }

            return Request.CreateResponse(HttpStatusCode.OK,result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// does thelogin operation
        /// </summary>
        /// <param name="user">contains only email and password for the user, rest needs to be hydrated form the server</param>
        /// <returns>resposem message</returns>
        public HttpResponseMessage getLoginUser(LoginUser user)
        {
            LoginUser result = default(LoginUser);
            if (String.IsNullOrWhiteSpace(user.email) || String.IsNullOrWhiteSpace(user.password)) {
                //this is not a valid login should be sent back as a bad request
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ArgumentException("Email or password cannot be null.."));
            }
            using (MinerContext db = new MinerContext()) {
                //getting the contextual employee
                var employee = db.Employees.Where(x => x.Email == user.email).FirstOrDefault();
                if (employee==null) {
                    return Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ArgumentException("Not an ENGSP employee? contact admin and get registered"));
                }

                //testing to see if the employee is a manager
                Manager manager = db.Managers.Where(x => x.Id == employee.Id).FirstOrDefault();
                if (manager ==null) {
                     return Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ArgumentException("Not an ENGSP manager ? contact admin for resolution"));
                }
                var isvalidPasswd = manager.Id.ToString() == user.password;
                if (!isvalidPasswd) {
                    return Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ArgumentException("Incorrect password.."));
                }
                //validation of the passwd

                //serialization of the obejct from the database
                result = Mapping.ToWeb<Employee, LoginUser>(employee);
                if (result ==null) {
                    return Request.CreateErrorResponse(HttpStatusCode.InternalServerError,
                        "Something inside the server went wrong!");
                }
                //fitting up the extra information for the webapp
                result.authentic = true;
                result.role = "manager";
                result.password = result.id.ToString();
            }
            //sending thsi back to the webapp
            return Request.CreateResponse(HttpStatusCode.OK, result);
        }
Exemplo n.º 8
0
 public WalletController(MinerContext dbContext, WalletService walletService, HashingService hashService)
 {
     DbContext     = dbContext;
     WalletService = walletService;
     HashService   = hashService;
 }
Exemplo n.º 9
0
 public MinerController(MinerContext dbContext, MinerService minerService, CustomizationOption customizationOptions)
 {
     DbContext            = dbContext;
     MinerService         = minerService;
     CustomizationOptions = customizationOptions;
 }
Exemplo n.º 10
0
 public PoolController(CustomizationOption customizationOptions, MinerContext dbContext)
 {
     CustomizationOptions = customizationOptions;
     DbContext            = dbContext;
 }
 public PlotterAuthenticationHandler(IOptionsMonitor <PlotterAuthenticationOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock,
                                     MinerContext dbContext)
     : base(options, logger, encoder, clock)
 {
     DbContext = dbContext;
 }
Exemplo n.º 12
0
 public PlotterController(MinerContext dbContext, PlotterService plotterService)
 {
     DbContext      = dbContext;
     PlotterService = plotterService;
 }
Exemplo n.º 13
0
 public PlotterController(MinerContext dbContext, PlotterService plotterService, CustomizationOption customizationOptions)
 {
     DbContext            = dbContext;
     PlotterService       = plotterService;
     CustomizationOptions = customizationOptions;
 }
Exemplo n.º 14
0
 public PlotController(PlotterService plotterService, MinerContext dbContext)
 {
     PlotterService = plotterService;
     DbContext      = dbContext;
 }
Exemplo n.º 15
0
 public UserController(MinerContext dbContext)
 {
     DbContext = dbContext;
 }
Exemplo n.º 16
0
 public MinerController(MinerContext dbContext, MinerService minerService)
 {
     DbContext    = dbContext;
     MinerService = minerService;
 }
Exemplo n.º 17
0
 public WalletController(MinerContext dbContext, WalletService walletService)
 {
     DbContext     = dbContext;
     WalletService = walletService;
 }
Exemplo n.º 18
0
 public CertificateController(MinerContext dbContext)
 {
     DbContext = dbContext;
 }