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)); }