Esempio n. 1
0
        public JsonResult UpdateProduct(APIProduct _product)
        {
            var restResult = new RestModel();

            try
            {
                product updateModel = new product();
                updateModel = db.products.Find(_product.id);

                updateModel.cat_id = _product.cat_id;
                updateModel.name   = _product.name;
                updateModel.price  = _product.price;
                updateModel.img    = _product.img;
                updateModel.note   = _product.note;

                db.Entry(updateModel).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                restResult.status = true;
            }
            catch (Exception ex)
            {
                restResult.status  = false;
                restResult.message = ex.Message;
            }

            return(Json(restResult, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public JsonResult InsertProduct(APIProduct _product)
        {
            var restResult = new RestModel();

            try
            {
                db.products.Add(new product()
                {
                    cat_id     = _product.cat_id,
                    name       = _product.name,
                    price      = _product.price,
                    img        = _product.img,
                    note       = _product.note,
                    is_deleted = 0
                });
                db.SaveChanges();
                restResult.status = true;
            }
            catch (Exception ex)
            {
                restResult.status  = false;
                restResult.message = ex.Message;
            }
            return(Json(restResult, JsonRequestBehavior.AllowGet));
        }
 public JWT_Payload(int partnerId, int siteId, APIProduct apiProduct)
 {
     Iss           = partnerId;
     Exp           = TWP_API_UTILS.GetUnixEpochTimestamp(DateTime.UtcNow.AddSeconds(JWT_EXPIRATION_SECONDS));
     Sub           = JWT_PARTNER_SUBJECT;
     SiteInfo.Type = JWT_SITE_TYPE_ID;
     SiteInfo.Id   = siteId;
     Product       = TWP_API_UTILS.APIProductToken[apiProduct];
 }
Esempio n. 4
0
 public JWT_Payload(int partnerId, int siteId, APIProduct apiProduct)
 {
     Iss           = partnerId;
     Exp           = TWPApiUtil.GetUnixEpochTimeStamp(DateTime.UtcNow.AddSeconds(JWT_Expiration_Seconds));
     Sub           = JWT_Partner_Subject;
     SiteInfo.Type = JWT_Site_Type_ID;
     SiteInfo.Id   = siteId;
     Product       = TWPApiUtil.aPIProductToken[apiProduct];
 }
        public async Task Post([FromBody] APIProduct value)
        {
            var product = new Product()
            {
                Id   = Guid.NewGuid(),
                Name = "SmartPhone"
            };

            await productCatalogService.AddProduct(product);
        }
Esempio n. 6
0
        public static async Task <string> getSSOLink(string APISecret, int partnerId, int siteId, string APIToken, APIProduct ssoType, string ssoUserIdenfitier)
        {
            JWT_Payload ssoPayload = new JWT_Payload(partnerId, siteId, ssoType)
            {
                User = new JWT_UserInfo(ssoUserIdenfitier)
            };

            string ssoURL = TWPApiUtil.Base_Employee_SSO_EndPoint;

            if (ssoType == APIProduct.TWP_Supervisor_SSO)
            {
                ssoURL = TWPApiUtil.Base_Supervisor_SSO_EndPoint;
                ssoPayload.User.Type = JWT_Payload.JWT_Supervisor_Type_ID;
            }

            return(ssoURL + await GetJWTToken(APISecret, ssoPayload));
        }
Esempio n. 7
0
 public static async Task <string> GetJWTToken(string APISecret, int partnerId, int siteId, APIProduct product = APIProduct.TWP_Partner)
 {
     return(await GetJWTToken(APISecret, new JWT_Payload(partnerId, siteId, product)));
 }
        public static async Task <string> GetSSOLink(string apiSecret, int partnerId, int siteId, string apiToken, APIProduct ssoType, string ssoUserIdentifier)
        {
            JWT_Payload ssoPayload = new JWT_Payload(partnerId, siteId, ssoType)
            {
                User = new JWT_UserInfo(ssoUserIdentifier)
            };

            string ssoUrl = TWP_API_UTILS.BASE_EMPLOYEE_SSO_ENDPOINT;

            if (ssoType == APIProduct.TWP_Supervisor_SSO)
            {
                ssoUrl = TWP_API_UTILS.BASE_SUPERVISOR_SSO_ENDPOINT;
                ssoPayload.User.Type = JWT_Payload.JWT_SUPERVISOR_TYPE_ID;
            }

            return(ssoUrl + await GetJWTToken(apiSecret, ssoPayload));
        }
Esempio n. 9
0
 public string this[APIProduct product] => API_Product_Token[(int)product];
Esempio n. 10
0
 public string this[APIProduct product] => API_PRODUCT_TOKEN[(int)product];