public async System.Threading.Tasks.Task Fill(CargarDatosContext dataContext)
        {
            String Baseurl = ConstantHelpers.AddKey("urlbase");
            var    result  = await ConstantHelpers.GetUrlAsync(Baseurl, "SAV/brands");

            LstBrand = JsonConvert.DeserializeObject <List <BrandEntity> >(result.Data.ToString());
        }
        public async System.Threading.Tasks.Task Fill(CargarDatosContext dataContext, Int32?productBrandId)
        {
            String Baseurl = ConstantHelpers.AddKey("urlbase");
            var    result  = await ConstantHelpers.GetUrlAsync(Baseurl, "SAV/entryexitproducs/" + productBrandId.ToString());

            LstEntryExitProduct = JsonConvert.DeserializeObject <List <EntryExitProductEntity> >(result.Data.ToString());
        }
Beispiel #3
0
        public async System.Threading.Tasks.Task FillAdd(CargarDatosContext dataContext)
        {
            var localId = dataContext.session.GetLocalId();
            var userId  = dataContext.session.GetUserId();

            String Baseurl = ConstantHelpers.AddKey("urlbase");

            LstSaleDetail = new List <SaleDetailEntity>();

            var resultLocal = await ConstantHelpers.GetUrlAsync(Baseurl, "SAV/locals");

            LstLocal = JsonConvert.DeserializeObject <List <LocalEntity> >(resultLocal.Data.ToString());

            var resultUser = await ConstantHelpers.GetUrlAsync(Baseurl, "SAV/users");

            LstUser = JsonConvert.DeserializeObject <List <UserEntity> >(resultUser.Data.ToString());

            var resultSale = await ConstantHelpers.GetUrlAsync(Baseurl, "SAV/sales");

            var LstSale = JsonConvert.DeserializeObject <List <SaleEntity> >(resultSale.Data.ToString());

            var resultCustomer = await ConstantHelpers.GetUrlAsync(Baseurl, "SAV/customers");

            LstCustomer = JsonConvert.DeserializeObject <List <CustomerEntity> >(resultCustomer.Data.ToString());

            var resultProductBrand = await ConstantHelpers.GetUrlAsync(Baseurl, "SAV/productbrands");

            LstProductBrand = JsonConvert.DeserializeObject <List <ProductBrandEntity> >(resultProductBrand.Data.ToString());


            CodeVoucher = NumberVoucher(LstSale);
        }
Beispiel #4
0
        public async Task <ActionResult> Login(LoginEntity model)
        {
            try
            {
                String Baseurl = ConstantHelpers.AddKey("urlbase");
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(Baseurl);
                    client.DefaultRequestHeaders.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    var content = new FormUrlEncodedContent(new[]
                    {
                        new KeyValuePair <string, string>("Credential", model.Credential),
                        new KeyValuePair <string, string>("Password", model.Password)
                    });
                    var result = await client.PostAsync("SAV/login", content);

                    string resultContent = result.Content.ReadAsStringAsync().Result;
                    var    obj           = JsonConvert.DeserializeObject <ResultRequestEntity>(resultContent);

                    var user = JsonConvert.DeserializeObject <List <UserEntity> >(obj.Data.ToString());

                    Session.Set(SessionKey.UserId, user[0].UserId);
                    Session.Set(SessionKey.FullName, user[0].Names + " " + user[0].Last_Names);
                    Session.Set(SessionKey.LocalId, user[0].LocalId);

                    if (!obj.Error)
                    {
                        return(RedirectToAction("ListSale", "Sale"));
                    }
                    PostMessage(HelperKit.Mvc.MessageType.Danger, obj.Data.ToString());
                    return(View(model));
                }
            }
            catch (Exception ex) {
                TryUpdateModel(model);
                return(View(model));
            }
        }