Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            PinCodes pinCodes = db.PinCodes.Find(id);

            db.PinCodes.Remove(pinCodes);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public ActionResult Edit(PinCodesViewModel model)
        {
            PinCodes pin = new PinCodes();

            pin.Id_PinCode     = model.Id_PinCode;
            pin.PinCode        = model.PinCode;
            pin.CreatedAt      = model.CreatedAt;
            pin.LastModifiedAt = DateTime.Now;
            pin.DeletedAt      = model.DeletedAt;
            pin.Active         = model.Active;


            int customerId = model.Id_Customer ?? 0;

            if (customerId > 0)

            {
                Customers cus = db.Customers.Find(customerId);
                pin.Id_Customer = customerId;
                pin.Id_Customer = cus.Id_Customer;
            }
            ViewBag.CustomerName = new SelectList((from c in db.Customers select new { Id_Customer = c.Id_Customer, CustomerName = c.CustomerName }), "Id_Customer", "CustomerName", pin.Id_Customer);

            int contractorId = model.Id_Contractor ?? 0;

            if (contractorId > 0)

            {
                Contractors con = db.Contractors.Find(contractorId);
                pin.Id_Contractor = customerId;
                pin.Id_Contractor = con.Id_Contractor;
            }

            ViewBag.CompanyName = new SelectList((from co in db.Contractors select new { Id_Contractor = co.Id_Contractor, CompanyName = co.CompanyName }), "Id_Contractor", "CompanyName", pin.Id_Contractor);

            int employeeId = model.Id_Employee ?? 0;

            if (employeeId > 0)

            {
                Employees emp = db.Employees.Find(employeeId);
                pin.Id_Employee = employeeId;
                pin.Id_Employee = emp.Id_Employee;
            }
            ViewBag.FirstName = new SelectList((from c in db.Employees select new { Id_Employee = c.Id_Employee, FirstName = c.FirstName }), "Id_Employee", "FirstName", pin.Id_Employee);
            ViewBag.LastName  = new SelectList((from c in db.Employees select new { Id_Employee = c.Id_Employee, LastName = c.LastName }), "Id_Employee", "LastName", pin.Id_Employee);

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }//edit
Esempio n. 3
0
        }//Index

        // GET: PinCodes/Details/5
        public ActionResult Details(int?id)
        {
            PinCodesViewModel model = new PinCodesViewModel();

            MobileWorkDataEntities entities = new MobileWorkDataEntities();

            try
            {
                PinCodes pincodedetail = entities.PinCodes.Find(id);
                if (pincodedetail == null)
                {
                    return(HttpNotFound());
                }

                // muodostetaan näkymämalli tietokannan rivien pohjalta
                PinCodesViewModel view = new PinCodesViewModel();
                view.Id_PinCode     = pincodedetail.Id_PinCode;
                view.PinCode        = pincodedetail.PinCode;
                view.CreatedAt      = pincodedetail.CreatedAt;
                view.LastModifiedAt = pincodedetail.LastModifiedAt;
                view.DeletedAt      = pincodedetail.DeletedAt;
                view.Active         = pincodedetail.Active;

                view.Id_Customer     = pincodedetail.Customers?.Id_Customer;
                view.CustomerName    = pincodedetail.Customers?.CustomerName;
                ViewBag.CustomerName = new SelectList((from c in db.Customers select new { Id_Customer = c.Id_Customer, CustomerName = c.CustomerName }), "Id_Customer", "CustomerName", null);

                view.Id_Contractor  = pincodedetail.Contractors?.Id_Contractor;
                view.CompanyName    = pincodedetail.Contractors?.CompanyName;
                ViewBag.CompanyName = new SelectList((from co in db.Contractors select new { Id_Contractor = co.Id_Contractor, CompanyName = co.CompanyName }), "Id_Contractor", "CompanyName", null);

                view.Id_Employee = pincodedetail.Employees?.Id_Employee;
                view.FirstName   = pincodedetail.Employees?.FirstName;
                view.LastName    = pincodedetail.Employees?.LastName;

                model = view;
            }
            finally
            {
                entities.Dispose();
            }
            return(View(model));
        }//details
    public HelperMiddleware(IMiddleware next, StatsPlugin statsPlugin, JsonStoragePlugin jsonStoragePlugin)
        : base(next)
    {
        _r = new Random();
        this._statsPlugin    = statsPlugin;
        _jsonStoragePlugin   = jsonStoragePlugin;
        this.HandlerMappings = new HandlerMapping[1]
        {
            new HandlerMapping()
            {
                ValidHandles  = new[] { new AlwaysMatchHandle() },
                Description   = "Supreme Ruler Roger Ver does not need to explain himself to you",
                EvaluatorFunc = DiscourseSearch
            }
        };
        jokes               = jsonStoragePlugin.ReadFile <Joke>("jokes").ToList();
        PinCodes            = jsonStoragePlugin.ReadFile <PinCode>("pincodes").ToList();
        UpdateSubscriptions = jsonStoragePlugin.ReadFile <UpdateSubscription>("subscriptions").ToList();
        if (!jokes.Any())
        {
            jokes.Add(new Joke()
            {
                Content = "bcash is the superior cryptocurrency because big blocks are cool, I guess"
            });
        }

        if (!PinCodes.Any())
        {
            PinCodes.Add(new PinCode()
            {
                Pin    = "7dd7aa3a-a5e3-42d5-b651-1de152c75bcb",
                UserId = "U96S14QGY"
            });
        }

        _httpClient = new HttpClient();
    }
Esempio n. 5
0
        public ActionResult Create(CustomersViewModel model)
        {
            MobileWorkDataEntities entities = new MobileWorkDataEntities();

            Customers cus = new Customers();

            cus.CustomerName   = model.CustomerName;
            cus.ContactPerson  = model.ContactPerson;
            cus.PhoneNumber    = model.PhoneNumber;
            cus.EmailAddress   = model.EmailAddress;
            cus.CreatedAt      = DateTime.Now;
            cus.LastModifiedAt = DateTime.Now;
            cus.Active         = model.Active;

            db.Customers.Add(cus);

            PinCodes pic = new PinCodes();

            pic.PinCode = model.PinCode;
            //usr.Password = "******";
            pic.Customers   = cus;
            ViewBag.PinCode = new SelectList((from p in db.PinCodes select new { Id_PinCode = p.Id_PinCode, PinCode = p.PinCode }), "Id_PinCode", "PinCode", null);


            db.PinCodes.Add(pic);

            try
            {
                db.SaveChanges();
            }

            catch (Exception ex)
            {
            }

            return(RedirectToAction("Index"));
        }//create
Esempio n. 6
0
        }//edit

        // GET: PinCodes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PinCodes pincodedetail = db.PinCodes.Find(id);

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

            PinCodesViewModel view = new PinCodesViewModel();

            view.Id_PinCode     = pincodedetail.Id_PinCode;
            view.PinCode        = pincodedetail.PinCode;
            view.CreatedAt      = pincodedetail.CreatedAt;
            view.LastModifiedAt = DateTime.Now;
            view.DeletedAt      = DateTime.Now;
            view.Active         = pincodedetail.Active;

            view.Id_Customer     = pincodedetail.Customers?.Id_Customer;
            view.CustomerName    = pincodedetail.Customers?.CustomerName;
            ViewBag.CustomerName = new SelectList((from c in db.Customers select new { Id_Customer = c.Id_Customer, CustomerName = c.CustomerName }), "Id_Customer", "CustomerName", view.Id_Customer);

            view.Id_Contractor  = pincodedetail.Contractors?.Id_Contractor;
            view.CompanyName    = pincodedetail.Contractors?.CompanyName;
            ViewBag.CompanyName = new SelectList((from co in db.Contractors select new { Id_Contractor = co.Id_Contractor, CompanyName = co.CompanyName }), "Id_Contractor", "CompanyName", view.Id_Contractor);

            view.Id_Employee = pincodedetail.Employees?.Id_Employee;
            view.FirstName   = pincodedetail.Employees?.FirstName;
            view.LastName    = pincodedetail.Employees?.LastName;

            return(View(view));
        }
Esempio n. 7
0
        public ActionResult Edit(CustomersViewModel model)
        {
            Customers cus = new Customers();

            cus.CustomerName   = model.CustomerName;
            cus.ContactPerson  = model.ContactPerson;
            cus.PhoneNumber    = model.PhoneNumber;
            cus.EmailAddress   = model.EmailAddress;
            cus.CreatedAt      = model.CreatedAt;
            cus.LastModifiedAt = DateTime.Now;
            cus.DeletedAt      = model.DeletedAt;
            cus.Active         = model.Active;

            if (cus.PinCodes == null)
            {
                PinCodes pic = new PinCodes();
                pic.PinCode = model.PinCode;
                //usr.Password = "******";
                pic.Customers = cus;

                db.PinCodes.Add(pic);
            }
            else
            {
                PinCodes pic = cus.PinCodes.FirstOrDefault();
                if (pic != null)
                {
                    pic.PinCode = model.PinCode;
                }
            }

            ViewBag.PinCode = new SelectList((from u in db.PinCodes select new { Id_PinCode = u.Id_PinCode, PinCode = u.PinCode }), "Id_PinCode", "PinCode", null);

            db.SaveChanges();
            return(View("Index"));
        }//edit
Esempio n. 8
0
        public ActionResult Create(PinCodesViewModel model)
        {
            MobileWorkDataEntities entities = new MobileWorkDataEntities();

            PinCodes pin = new PinCodes();

            pin.Id_PinCode     = model.Id_PinCode;
            pin.PinCode        = model.PinCode;
            pin.CreatedAt      = DateTime.Now;
            pin.LastModifiedAt = DateTime.Now;
            pin.DeletedAt      = model.DeletedAt;
            pin.Active         = model.Active;

            db.PinCodes.Add(pin);

            int customerId = int.Parse(model.CustomerName);

            if (customerId > 0)
            {
                Customers cus = db.Customers.Find(customerId);
                pin.Id_Customer = cus.Id_Customer;
            }

            ViewBag.CustomerName = new SelectList((from c in db.Customers select new { Id_Customer = c.Id_Customer, CustomerName = c.CustomerName }), "Id_Customer", "CustomerName", null);

            int contractorId = int.Parse(model.CompanyName);

            if (contractorId > 0)
            {
                Contractors con = db.Contractors.Find(contractorId);
                pin.Id_Contractor = con.Id_Contractor;
            }



            int employeeId = int.Parse(model.FirstName);

            if (employeeId > 0)
            {
                Employees emp = db.Employees.Find(employeeId);
                pin.Id_Employee = emp.Id_Employee;
            }

            int employLastId = int.Parse(model.LastName);

            if (employLastId > 0)
            {
                Employees emp = db.Employees.Find(employLastId);
                pin.Id_Employee = emp.Id_Employee;
            }

            try
            {
                db.SaveChanges();
            }

            catch (Exception ex)
            {
            }

            return(RedirectToAction("Index"));
        }//create
Esempio n. 9
0
 private int getPin(string programName)
 {
     return(PinCodes.Where(x => x.ProgramName == programName).First().Pin);
 }