private void TaoTuyenVeXe(StateProvince Province1, StateProvince Province2, Decimal price, ENKieuXe kieuxe) { var checkitems = _tuyenvexeRepository.Table.Where(c => c.Province1Id == Province1.Id && c.Province2Id == Province2.Id && c.KieuXeId == (int)kieuxe).ToList(); var item = new TuyenVeXe(); if (checkitems.Count > 0) { item = checkitems.First(); //chi update neu gia < gia hien tai if (item.PriceNew > price) { item.PriceNew = price; _tuyenvexeRepository.Update(item); } } else { item.Province1Id = Province1.Id; item.Province2Id = Province2.Id; item.PriceNew = price; item.HienThi = true; item.ToWeb = true; item.ThuTu = 0; item.KieuXe = kieuxe; _tuyenvexeRepository.Insert(item); string seourlname = string.Format("Vé xe tuyến {0} {1} {2}", Province1.Name, Province2.Name, item.Id, item.Id); seourlname = Chonves.CVCommon.convertToUnSign(seourlname); SaveSlug(item, item.ValidateSeName("", seourlname, true), 0); } }
void TuyenVeXeToMode(TuyenVeXe e, TuyenVeXeModel m) { m.Id = e.Id; m.Province1Id = e.Province1Id; m.TenTinhDi = e.Province1.Name; m.Province2Id = e.Province2Id; m.TenTinhDen = e.Province2.Name; m.PriceOld = e.PriceOld; m.PriceNew = e.PriceNew; m.PriceOldText = _priceFormatter.FormatPrice(m.PriceOld, true, false); m.PriceNewText = _priceFormatter.FormatPrice(m.PriceNew, true, false); m.SeName = e.GetSeName(); }