예제 #1
0
 public ActionResult Edit(int?id)
 {
     if (id != null)
     {
         Organisations o = OrganisationDA.GetOrganisation(Convert.ToInt32(id));
         return(View(o));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
        public override Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            string       mode     = context.UserName.Substring(0, 1);
            Organisation o        = null;
            bool         fail     = true;
            string       username = context.UserName.Substring(1);

            switch (mode)
            {
            case "m":
                o = OrganisationDA.CheckCredentials(username, context.Password);
                if (o != null)
                {
                    fail = false;
                }
                break;

            case "s":
                o = OrganisationDA.GetOrganisation(Int32.Parse(username));
                Employee employee = EmployeeDA.GetEmployeeByName(context.Password, o);
                if (o != null && employee != null)
                {
                    fail = false;
                }
                break;

            case "r":
                o = OrganisationDA.GetOrganisation(Int32.Parse(username));
                Customer customer = CustomerDA.GetCustomerByName(context.Password, o);
                if (o != null && customer != null)
                {
                    fail = false;
                }
                break;
            }
            if (fail)
            {
                context.Rejected();
                return(Task.FromResult(0));
            }

            var id = new ClaimsIdentity(context.Options.AuthenticationType);

            id.AddClaim(new Claim("userid", o.ID.ToString()));
            id.AddClaim(new Claim("dbname", o.DbName));
            id.AddClaim(new Claim("dblogin", o.DbLogin));
            id.AddClaim(new Claim("dbpass", o.DbPassword));

            context.Validated(id);
            return(Task.FromResult(0));
        }
 public ActionResult Search(int?id)
 {
     if (id != null)
     {
         Organisations o = OrganisationDA.GetOrganisation(Convert.ToInt32(id));
         ViewBag.Titel = "Kassas voor " + o.OrganisationName;
         List <RegisterPM> list = RegistersDA.GetRegistersPM(o.ID);
         return(View(list));
     }
     else
     {
         return(RedirectToAction("Index", "Organisations"));
     }
 }
예제 #4
0
        public ActionResult Create(PMOrganisationRegister reg)
        {
            reg.Organisations = GetOrganisations();

            if (ModelState.IsValid)
            {
                reg.DataOrganisationRegister.Organisation = OrganisationDA.GetOrganisation(reg.DataOrganisationRegister.OrganisationID);
                int id = RegisterDA.Save(reg.DataOrganisationRegister);

                return(RedirectToAction("Index"));
            }

            return(View(reg));
        }
예제 #5
0
        public ActionResult Edit(int id)
        {
            Organisation org = OrganisationDA.GetOrganisation(id);

            if (org == null)
            {
                return(HttpNotFound());
            }

            return(View(new OrganisationEditModel()
            {
                ID = org.ID,
                Login = org.Login,
                Password = org.Password,
                OrganisationName = org.OrganisationName,
                Address = org.Address,
                Email = org.Email,
                Phone = org.Phone
            }));
        }
예제 #6
0
        public SalesAuth AuthSales([FromBody] SalesAuth data)
        {
            try
            {
                Organisation org      = OrganisationDA.GetOrganisation(data.OrganisationID);
                Employee     employee = EmployeeDA.GetEmployeeByName(data.EmployeeName, org);

                if (employee != null)
                {
                    data.Authorized = true;
                    data.EmployeeID = employee.ID;
                }

                return(data);
            }
            catch (Exception)
            {
                return(null);
            }

            return(new SalesAuth());
        }
예제 #7
0
        public ActionResult Details(int id)
        {
            Organisation org = OrganisationDA.GetOrganisation(id);

            return(View(org));
        }