public int InsertCityAndPrice(CityAndPriceDto model)
        {
            try
            {
                var operationType = model.Id > 0 ? "UPD" : "INS";

                var cn  = new SqlConnection(connStr);
                var cmd = new SqlCommand("prdCityForPriceOperation", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Id", model.Id);
                cmd.Parameters.AddWithValue("@ToCityId", model.ToCityId);
                cmd.Parameters.AddWithValue("@FromCityId", model.FromCityId);
                cmd.Parameters.AddWithValue("@Price", model.Price);
                cmd.Parameters.AddWithValue("@CompanyId", model.CompanyId);
                cmd.Parameters.AddWithValue("@OperationType", operationType);
                cn.Open();
                var result = (int)cmd.ExecuteNonQuery();

                cn.Close();
                return(result);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Exemple #2
0
        public ActionResult NewCityForPrice(CityAndPriceDto model)
        {
            LoginControl();
            var service = new CommonService();

            var result = service.InsertCityAndPrice(model);

            ViewBag.fromCity = service.GetCity();
            ViewBag.toCity   = service.GetCity();
            ViewBag.company  = service.GetCompany();
            return(RedirectToAction("CityForPrice"));
        }