Example #1
0
        public void SaveRating(double number_of_stars, int product_id)
        {
            RATE r = new RATE {
                Number_Of_Stars = number_of_stars, Id_Product = product_id
            };

            db.RATE.Add(r);
            db.SaveChanges();

            // Tính lại các biến xếp hạng
            // Đếm tổng số lượt xếp hạng sản phẩm
            var listRate = db.RATE.Where(x => x.Id_Product == product_id);

            TotalRate = listRate.Count();

            // Đếm số lượt của mỗi bậc xếp hạng
            ListCountRate = new int[5];
            for (int i = 0; i < 5; i++)
            {
                ListCountRate[i] = db.RATE.Where(x => x.Id_Product == product_id && x.Number_Of_Stars == i + 1).Count();
            }

            // Tính xếp hạng trung bình
            if (TotalRate > 0)
            {
                AverageRate = listRate.Average(x => x.Number_Of_Stars);
            }
            else
            {
                AverageRate = 0;
            }
        }
        public ResultModel updateRate(RATE model)
        {
            ResultModel result = new ResultModel();

            try
            {
                if (model.ridx == 0)
                {
                    HyundaiContext.AddToRATE(model);
                }
                else
                {
                    RATE entity    = HyundaiContext.RATE.Where(c => c.ridx == model.ridx).FirstOrDefault();
                    RATE newEntity = Mapper.Map(model, entity);
                    newEntity.RegId = entity.RegId;
                    HyundaiContext.RATE.ApplyCurrentValues(newEntity);
                }

                HyundaiContext.SaveChanges();
            }
            catch (Exception ex)
            {
                result.ResultCode    = -1;
                result.ResultMessage = ex.Message;
                throw ex;
            }
            return(result);
        }
Example #3
0
 public override string ToString()
 {
     return(GetType() + " " + JobNumber + " " + Customer + " " +
            Description + " " + Hours + " hours @" + RATE.ToString("C") +
            " per hour. Rush job adds " + PREMIUM +
            " premium. Total price is " + Price.ToString("C"));
 }
Example #4
0
    public static RATE GetRATEByID(int id)
    {
        RATE            rATE            = new RATE();
        SqlRATEProvider sqlRATEProvider = new SqlRATEProvider();

        rATE = sqlRATEProvider.GetRATEByID(id);
        return(rATE);
    }
Example #5
0
        public RATE Update(string id, RATE rATE)
        {
            var savedCurrency = _currencyRepository.Read();

            if (savedCurrency == null)
            {
                throw new Exception("Error, try again");
            }
            else
            {
                return(_currencyRepository.Update(id, rATE));
            }
        }
Example #6
0
        private static void RectToRate(RECT win_rect, RECT screen_rect, out RATE win_rate)
        {
            win_rate = new RATE();

            win_rate.x = ((double)win_rect.left - screen_rect.left)
                         / ((double)screen_rect.right - screen_rect.left);
            win_rate.y = ((double)win_rect.top - screen_rect.top)
                         / ((double)screen_rect.bottom - screen_rect.top);
            win_rate.width = ((double)win_rect.right - win_rect.left)
                             / ((double)screen_rect.right - screen_rect.left);
            win_rate.height = ((double)win_rect.bottom - win_rect.top)
                              / ((double)screen_rect.bottom - screen_rect.top);
        }
Example #7
0
        public RATE Update(RATE rate, string country)
        {
            var updatedRate = _currencyRepository.Read(country);

            if (updatedRate != null)
            {
                return(_currencyRepository.Update(rate, country));
            }
            else
            {
                throw new Exception("Rate not found!");
            }
        }
Example #8
0
    public bool UpdateRATE(RATE rATE)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("AbiMatuEnterprise_UpdateRATE", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@RATEID", SqlDbType.Int).Value      = rATE.RATEID;
            cmd.Parameters.Add("@MINAMT", SqlDbType.Int).Value      = rATE.MINAMT;
            cmd.Parameters.Add("@MAXAMT", SqlDbType.Int).Value      = rATE.MAXAMT;
            cmd.Parameters.Add("@RATEVALUE", SqlDbType.Int).Value   = rATE.RATEVALUE;
            cmd.Parameters.Add("@POINTS", SqlDbType.Int).Value      = rATE.POINTS;
            cmd.Parameters.Add("@POINTSVALUE", SqlDbType.Int).Value = rATE.POINTSVALUE;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return(result == 1);
        }
    }
Example #9
0
        public ActionResult updateRate(RATE model)
        {
            ResultModel result = new ResultModel();

            try
            {
                model.RegId   = userInfo.uidx;
                model.RegDate = DateTime.Now;
                result        = custService.updateRate(model);
            }
            catch (Exception ex)
            {
                result.ResultCode    = -1;
                result.ResultMessage = ex.Message;
                throw ex;
            }

            return(Json(result));
        }
Example #10
0
 public RATE GetRATEFromReader(IDataReader reader)
 {
     try
     {
         RATE rATE = new RATE
                     (
             (int)reader["RATEID"],
             (int)reader["MINAMT"],
             (int)reader["MAXAMT"],
             (int)reader["RATEVALUE"],
             (int)reader["POINTS"],
             (int)reader["POINTSVALUE"]
                     );
         return(rATE);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Example #11
0
        public void Save_LRates(List <Rates> LRates, string product, DateTime Date)
        {
            List <AsmodatSerialization.DataBase_Rates> LASDB_Rates = new List <DataBase_Rates>();

            foreach (Rates RATE in LRates)
            {
                LASDB_Rates.Add(RATE.ToDataBase());
            }

            product = product.Replace("/", "-");

            string directory = Directory_Rates + Date.Year + "+" + Date.Month + @"\";
            string PATCH     = directory + product + Extention_Rates;

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }
            this.Delete_LRates(product, Date);

            AsmodatSerialization.Operations.Save <List <AsmodatSerialization.DataBase_Rates> >(LASDB_Rates, PATCH);
        }
Example #12
0
        public ActionResult Put(string country, [FromBody] RATE rate)
        {
            var result = _currencyService.Update(rate, country);

            return(new JsonResult(result));
        }
Example #13
0
 public ANALOG(ANALOG _origin)
 {
     hRate = new RATE(_origin.hRate);
     vRate = new RATE(_origin.vRate);
 }
Example #14
0
 public ANALOG()
 {
     hRate = new RATE();
     vRate = new RATE();
 }
Example #15
0
 public RATE(RATE _origin)
 {
     mRate = (_origin != null) ? _origin.mRate : 0;
 }
Example #16
0
 public RATE(RATE _origin)
 {
     mRate = (_origin!=null) ? _origin.mRate : 0;
 }
Example #17
0
        public ActionResult Post([FromBody] RATE rate)
        {
            var result = _currencyService.Create(rate);

            return(new JsonResult(result));
        }
Example #18
0
    public static bool UpdateRATE(RATE rATE)
    {
        SqlRATEProvider sqlRATEProvider = new SqlRATEProvider();

        return(sqlRATEProvider.UpdateRATE(rATE));
    }
 public ActionResult <RATE> Post(RATE rATE)
 {
     return(_currencyService.CreateCurrency(rATE));
 }
Example #20
0
 public RATE CreateCurrency(RATE rATE)
 {
     return(_currencyRepository.Create(rATE));
 }
Example #21
0
 public RATE Update(string id, RATE rATE)
 {
     _CurrencydbContext.Update(rATE);
     _CurrencydbContext.SaveChanges();
     return(rATE);
 }
Example #22
0
 public RATE Create(RATE rATE)
 {
     _CurrencydbContext.RATE.Add(rATE);
     _CurrencydbContext.SaveChanges();
     return(rATE);
 }
 public ActionResult <RATE> Put(string id, RATE rATE)
 {
     return(_currencyService.Update(id, rATE));
 }
Example #24
0
    public static int InsertRATE(RATE rATE)
    {
        SqlRATEProvider sqlRATEProvider = new SqlRATEProvider();

        return(sqlRATEProvider.InsertRATE(rATE));
    }
Example #25
0
        public RATE vRate; // 0-(DIV-1)

        #endregion Fields

        #region Constructors

        public ANALOG()
        {
            hRate = new RATE();
            vRate = new RATE();
        }
Example #26
0
 public RATE Create(RATE rate)
 {
     return(_currencyRepository.Create(rate));
 }
Example #27
0
 public ANALOG(ANALOG _origin)
 {
     hRate = new RATE(_origin.hRate);
     vRate = new RATE(_origin.vRate);
 }