Example #1
0
        public RestoraniDomainModel GetRestoransByOffset(int offset, int take)
        {
            RestoraniDomainModel restoranDomainModels = new RestoraniDomainModel();

            //var res = dbcontext.RestoranTbls.OrderBy(x => x.RestoranID).Skip(offset).Take(take).ToList();
            //int count = res.Count;
            //restoranDomainModels.TotalCount = dbcontext.RestoranTbls.ToList().Count;
            //for (int i = 0, j = count - 1; i < count; i++, j--)
            //{
            //    if (j < i) { break; }
            //    RestoranDomainModel restoranDomainModel = new RestoranDomainModel();
            //    restoranDomainModel.RestoranID = res[i].RestoranID;
            //    restoranDomainModel.Ime = res[i].Ime;
            //    restoranDomainModel.Koordinate = res[i].Koordinate;
            //    restoranDomainModel.Logo = res[i].Logo;
            //    restoranDomainModel.MinimalnaNarudzbina = res[i].MinimalnaNarudzbina;
            //    restoranDomainModel.Ocena = res[i].Ocena;
            //    RestoranDomainModel r = new RestoranDomainModel();
            //    r.RestoranID = res[j].RestoranID;
            //    r.Ime = res[j].Ime;
            //    r.Koordinate = res[j].Koordinate;
            //    r.Logo = res[j].Logo;
            //    r.MinimalnaNarudzbina = res[j].MinimalnaNarudzbina;
            //    r.Ocena = res[j].Ocena;
            //    restoranDomainModels.restoranDomainModels.Add(restoranDomainModel);
            //    restoranDomainModels.restoranDomainModels.Add(r);
            //}
            //restoranDomainModels.KuhinjeModels.AddRange(GetKuhinjes());
            return(restoranDomainModels);
        }
Example #2
0
        // GET: Ponuda
        public ActionResult Index(AddressInfo addressInfo)
        {
            if (ModelState.IsValid)
            {
                RestoraniDomainModel restoraniDomainModel = _restoranBusiness.GetRestoransByAll(addressInfo.skip, 10, addressInfo.opstina, addressInfo.postCode, addressInfo.restoran, "1");

                return(View(restoraniDomainModel));
            }

            RestoraniDomainModel restoran1 = _restoranBusiness.GetRestorans(10);

            return(View(restoran1));
        }
Example #3
0
        public ActionResult Search(string opstina, int postCode, string restoran, string kuhinje, int skip)
        {
            string [] kuhinjeObj = JsonConvert.DeserializeObject <string []>(kuhinje);
            string    kuhinjeNiz = "";

            if (kuhinje.Length > 0)
            {
                int currentConveted = 0;

                StringBuilder s = new StringBuilder();
                for (int i = 0; i < kuhinjeObj.Length; i++)
                {
                    if (kuhinjeObj[i] != null)
                    {
                        if (int.TryParse(kuhinjeObj[i], out currentConveted))
                        {
                            if (s.Length <= 0)
                            {
                                s.Append(kuhinjeObj[i]);
                            }
                            else if (i > 0 && i < kuhinjeObj.Length - 1)
                            {
                                s.Append(',');
                                s.Append(kuhinjeObj[i]);
                            }
                            else
                            {
                                s.Append(',');
                                s.Append(kuhinjeObj[i]);
                            }
                        }
                    }
                }
                kuhinjeNiz = s.ToString();
            }
            RestoraniDomainModel restoraniDomainModel = _restoranBusiness.GetRestoransByAll(skip, 10, opstina, postCode, restoran, kuhinjeNiz);

            if (restoraniDomainModel.restoranDomainModels.Count > 0)
            {
                Response.StatusCode = (int)HttpStatusCode.OK;
            }
            else
            {
                Response.StatusCode = (int)HttpStatusCode.NoContent;
            }
            return(PartialView("~/Views/Shared/_RestoraniList.cshtml", restoraniDomainModel));
        }
Example #4
0
        public RestoraniDomainModel GetRestorans(int initTake)
        {
            RestoraniDomainModel restoranDomainModels = new RestoraniDomainModel();


            string conString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

            try
            {
                DataSet ds = new DataSet();
                using (SqlConnection con = new SqlConnection(conString))
                {
                    using (SqlCommand com = new SqlCommand("spGetFirstElements", con))
                    {
                        com.CommandType = System.Data.CommandType.StoredProcedure;
                        com.Parameters.AddWithValue("@count", initTake);
                        if (con.State != System.Data.ConnectionState.Open)
                        {
                            con.Open();
                        }
                        if (con.State == System.Data.ConnectionState.Open)
                        {
                            using (SqlDataAdapter da = new SqlDataAdapter(com))
                            {
                                da.Fill(ds);
                            }
                        }
                    }
                }

                for (int i = 0, j = ds.Tables[0].Rows.Count - 1; i < ds.Tables[0].Rows.Count; i++, j--)
                {
                    if (j < i)
                    {
                        break;
                    }
                    restoranDomainModels.restoranDomainModels.Add(RestoranDomainModel(ds, i));
                    restoranDomainModels.restoranDomainModels.Add(RestoranDomainModel(ds, j));
                }
                for (int i = 0, j = ds.Tables[1].Rows.Count - 1; i < ds.Tables[1].Rows.Count; i++, j--)
                {
                    if (j < i)
                    {
                        break;
                    }
                    restoranDomainModels.KuhinjeModels.Add(KuhinjeModelsMethod(ds, i));
                    restoranDomainModels.KuhinjeModels.Add(KuhinjeModelsMethod(ds, j));
                }
                DataRow total = ds.Tables[2].Rows[0];
                restoranDomainModels.TotalCount = (int)total["Total"];
            }
            catch (SqlException ex)
            {
                string sqlerro = ex.Message;
            }
            catch (Exception ex)
            {
                string regularException = ex.Message;
            }

            return(restoranDomainModels);
        }
Example #5
0
        public RestoraniDomainModel GetRestoransPartialy(int offset, int take, string opstina, int postcode, string restoran, string kuhinje)
        {
            RestoraniDomainModel restoranDomainModels = new RestoraniDomainModel();


            string conString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

            try
            {
                DataSet ds = new DataSet();
                using (SqlConnection con = new SqlConnection(conString))
                {
                    using (SqlCommand com = new SqlCommand("spSearchBasicPartially", con))
                    {
                        com.CommandType = System.Data.CommandType.StoredProcedure;
                        com.Parameters.AddWithValue("@opstina", opstina);
                        com.Parameters.AddWithValue("@postCode", postcode);
                        com.Parameters.AddWithValue("@restorna", restoran);
                        com.Parameters.AddWithValue("@kuhinje", kuhinje);
                        com.Parameters.AddWithValue("@skip", offset);
                        if (con.State != System.Data.ConnectionState.Open)
                        {
                            con.Open();
                        }
                        if (con.State == System.Data.ConnectionState.Open)
                        {
                            using (SqlDataAdapter da = new SqlDataAdapter(com))
                            {
                                da.Fill(ds);
                            }
                        }
                    }
                }
                if (ds.Tables[0].Rows.Count > 1)
                {
                    for (int i = 0, j = ds.Tables[0].Rows.Count - 1; i < ds.Tables[0].Rows.Count; i++, j--)
                    {
                        if (j < i)
                        {
                            break;
                        }
                        restoranDomainModels.restoranDomainModels.Add(RestoranDomainModel(ds, i));
                        restoranDomainModels.restoranDomainModels.Add(RestoranDomainModel(ds, j));
                    }
                }
                else
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        restoranDomainModels.restoranDomainModels.Add(RestoranDomainModel(ds, i));
                    }
                }
            }
            catch (SqlException ex)
            {
                string sqlerro = ex.Message;
            }
            catch (Exception ex)
            {
                string regularException = ex.Message;
            }

            return(restoranDomainModels);
        }
Example #6
0
        public RestoraniDomainModel GetRestoransByOffsetAndCity(int offset, int take, string city)
        {
            RestoraniDomainModel restoranDomainModels = new RestoraniDomainModel();

            return(restoranDomainModels);
        }