Ejemplo n.º 1
0
 public virtual void DeleteChotKhach(ChotKhach _item)
 {
     if (_item == null)
     {
         throw new ArgumentNullException("NhaXe");
     }
     _chotkhachRepository.Delete(_item);
 }
Ejemplo n.º 2
0
 public virtual void InsertChotKhach(ChotKhach _item)
 {
     if (_item == null)
     {
         throw new ArgumentNullException("NhaXe");
     }
     _item.NgayChot = DateTime.Now;
     _chotkhachRepository.Insert(_item);
     _item.Ma = string.Format("CK{0}", _item.Id.ToString().PadLeft(7, '0'));
     UpdateChotKhach(_item);
 }
Ejemplo n.º 3
0
        public ActionResult ChotKhach(int NhaXeId, int XeXuatBenId, string Email, string Password, int slpm, int sltt, string Latitude, string Longitude, string VitriChot, string apiToken)
        {
            var loginresult = _customerRegistrationService.ValidateCustomer(Email, Password);

            if (loginresult != CustomerLoginResults.Successful)
            {
                return(ErrorOccured("Tài khoản hoặc mật khẩu không đúng !"));
            }
            var tkchot = _customerService.GetCustomerByEmail(Email);

            //luu nhat ky
            _customerActivityService.InsertActivity("PublicStore.Login", "Tài khoản nhà xe đăng nhập để chốt khách", tkchot);
            //lay thong tin van phong
            var nhanvienchot = _nhanvienService.GetByCustomerId(tkchot.Id);

            if (nhanvienchot == null)
            {
                return(ErrorOccured("Thông tin người chốt không hợp lệ"));
            }
            if (!nhanvienchot.DiemDonId.HasValue)
            {
                return(ErrorOccured("Thông tin người chốt không hợp lệ"));
            }
            xexuatben = _limousinebanveService.GetChuyenDiById(XeXuatBenId);
            if (xexuatben == null)
            {
                return(ErrorOccured("Không tồn tại thông tin xe xuất bến"));
            }
            if (xexuatben.NhaXeId != NhaXeId)
            {
                return(ErrorOccured("Xe xuất bến không thuộc nhà xe"));
            }
            //thuc hien thong tin chot khach
            //kiem tra co thong tin chot trc chua
            var lschotkhach = _nhaxeService.GetChotKhachs(NhaXeId, HistoryXeXuatBenId: XeXuatBenId);
            var itemck      = new ChotKhach();

            if (lschotkhach.Count > 0)
            {
                itemck = lschotkhach.FirstOrDefault();
            }
            itemck.SoLuongThucTe      = sltt;
            itemck.SoLuongPhanMem     = slpm;
            itemck.NguoiChotId        = nhanvienchot.Id;
            itemck.DiemDonId          = nhanvienchot.DiemDonId.Value;
            itemck.NgayChot           = DateTime.Now;
            itemck.NhaXeId            = NhaXeId;
            itemck.HistoryXeXuatBenId = xexuatben.Id;
            itemck.Latitude           = Convert.ToDecimal(Latitude) / 1000000000m;
            itemck.Longitude          = Convert.ToDecimal(Longitude) / 1000000000m;
            itemck.ViTriChot          = VitriChot;
            if (itemck.Id > 0)
            {
                _nhaxeService.UpdateChotKhach(itemck);
            }
            else
            {
                _nhaxeService.InsertChotKhach(itemck);
            }
            itemck = _nhaxeService.GetChotKhachById(itemck.Id);

            string ghichu     = string.Format("Chốt khách tại {0} : SL khách thực tế/phần mềm: {1}/{2}; người chốt: {3}", itemck.diemchot.TenDiemDon, sltt, slpm, nhanvienchot.HoVaTen);
            var    item       = CreateHistoryXeXuatBenLog(xexuatben.trangthai, ghichu, XeXuatBenId, nhanvienchot.Id);
            var    nhatkyinfo = new
            {
                Id      = item.Id,
                NgayTao = item.NgayTao.toStringDateTime(),
                GhiChu  = item.GhiChu
            };

            return(Successful(nhatkyinfo));
        }