public MessageReport UpdateSql(tblLocker obj)
        {
            MessageReport report;

            try
            {
                var query = new StringBuilder();
                query.AppendLine("UPDATE [dbo].[tblLocker]");
                query.AppendLine(string.Format("SET [Name] = N'{0}'", obj.Name));
                query.AppendLine(string.Format(",[ReaderIndex] = '{0}'", obj.ReaderIndex));
                query.AppendLine(string.Format(",[CardNo] = '{0}'", obj.CardNo));
                query.AppendLine(string.Format(",[CardNumber] = '{0}'", obj.CardNumber));
                query.AppendLine(string.Format(",[ControllerID] = '{0}'", obj.ControllerID));
                query.AppendLine(string.Format(",[LockerType] = '{0}'", obj.LockerType));
                query.AppendLine(string.Format("WHERE Id = '{0}'", obj.Id));

                ExcuteSQL.Execute(query.ToString());

                report = new MessageReport(true, "Cập nhật thành công");
            }
            catch (Exception ex)
            {
                report = new MessageReport(false, ex.InnerException != null ? ex.InnerException.ToString() : ex.Message);
            }
            return(report);
        }
        public MessageReport CreateSQL(tblLocker obj)
        {
            var str = new StringBuilder();

            str.AppendLine("INSERT INTO tblLocker (");

            str.AppendLine("Id, Name, ReaderIndex, CardNo, CardNumber, ControllerID, DateCreated, LockerType");

            str.AppendLine(") VALUES (");

            str.AppendLine(string.Format("'{0}', N'{1}', {2}, '{3}', '{4}', '{5}', GETDATE(), '0'", obj.Id, obj.Name, obj.ReaderIndex, obj.CardNo, obj.CardNumber, obj.ControllerID));

            str.AppendLine(")");

            var result = new MessageReport(false, "Có lỗi xảy ra");

            try
            {
                ExcuteSQL.Execute(str.ToString());
            }
            catch (Exception ex)
            {
                result = new MessageReport(false, ex.Message);
            }

            return(result);
        }
        public MessageReport DeleteById(string id)
        {
            var report = new MessageReport(false, "Có lỗi xảy ra");

            try
            {
                var obj = _RoleRepository.GetById(id);
                if (obj != null)
                {
                    obj.IsDeleted = true;

                    _RoleRepository.Update(obj);
                    Save();

                    report = new MessageReport(true, "Xóa thành công");
                }
            }
            catch (Exception ex)
            {
                report = new MessageReport(false, ex.Message);
            }

            _LogService.WriteLog(report, "Role", id, ActionConfig.Delete, user);

            return(report);
        }
Exemple #4
0
        public MessageReport DeleteById(string id)
        {
            var re = new MessageReport();

            re.Message   = "Error";
            re.isSuccess = false;

            try
            {
                var obj = GetById(id);
                if (obj != null)
                {
                    _ExcelColumnRepository.Delete(obj);

                    Save();

                    re.Message   = "Xóa thành công";
                    re.isSuccess = true;
                }
                else
                {
                    re.Message   = "Bản ghi không tồn tại";
                    re.isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                re.Message   = ex.Message;
                re.isSuccess = false;
            }

            return(re);
        }
        public MessageReport DeleteById(string id, ref string plate)
        {
            var result = new MessageReport();

            result.Message   = "Có lỗi xảy ra";
            result.isSuccess = false;

            try
            {
                var obj = GetById(id);
                if (obj != null)
                {
                    plate = obj.Plate;
                }

                var str = string.Format("UPDATE tblLoopEvent SET EventCode='2', IsDelete=1 WHERE Id = '{0}'", id);

                SqlExQuery <tblLoopEvent> .ExcuteNone(str);

                result.Message   = "Xóa thành công";
                result.isSuccess = true;
            }
            catch (Exception ex)
            {
                result.Message   = ex.Message;
                result.isSuccess = false;
            }

            return(result);
        }
Exemple #6
0
        public MessageReport DeleteById(string id)
        {
            var report = new MessageReport(false, "Co lỗi xảy ra");

            try
            {
                var student = _StudentRepository.GetById(id);
                if (student != null)
                {
                    if (!student.Active)
                    {
                        student.IsDelete = true;
                        _StudentRepository.Delete(student);
                        Save();
                        report = new MessageReport(true, "Xóa thành công");
                    }
                    else
                    {
                        report = new MessageReport(false, "Thông tin đang sử dụng. Không thể xóa.");
                    }
                }
                else
                {
                    report = new MessageReport(false, "Thông tin không tồn tại");
                }
            }
            catch (Exception ex)
            {
                report = new MessageReport(false, ex.InnerException != null ? ex.InnerException.ToString() : ex.Message);
            }
            return(report);
        }
        public MessageReport DeleteById(string id, ref tblFtpAccount obj)
        {
            var re = new MessageReport();

            re.Message   = "Error";
            re.isSuccess = false;

            try
            {
                obj = GetById(id);
                if (obj != null)
                {
                    _tblFtpAccountRepository.Delete(n => n.Id == id);

                    Save();

                    re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["DeleteSuccess"];
                    re.isSuccess = true;
                }
                else
                {
                    re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["record_does_not_exist"];
                    re.isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                re.Message   = ex.Message;
                re.isSuccess = false;
            }

            return(re);
        }
Exemple #8
0
        public MessageReport DeleteById(string id, ref BM_ApartmentRole obj)
        {
            var re = new MessageReport();

            re.Message   = "Error";
            re.isSuccess = false;

            try
            {
                obj = GetById(id);
                if (obj != null)
                {
                    obj.IsDeleted = true;
                    _BM_ApartmentRoleRepository.Update(obj);

                    Save();

                    re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["DeleteSuccess"];;
                    re.isSuccess = true;
                }
                else
                {
                    re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["record_does_not_exist"];;
                    re.isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                re.Message   = ex.Message;
                re.isSuccess = false;
            }

            return(re);
        }
        /// <summary>
        /// Xóa
        /// </summary>
        /// <modified>
        /// Author              Date            Comments
        /// TrungNQ             01/09/2017      Tạo mới
        /// </modified>
        /// <param name="id">Id bản ghi</param>
        /// <returns></returns>
        public JsonResult Delete(string id)
        {
            var obj = new tblGate();

            var listPC = _tblPCService.GetAllByGateId(id);

            if (listPC.Any())
            {
                var message = new MessageReport();

                message.isSuccess = false;
                message.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["Message_del_fail_computer"];

                return(Json(message, JsonRequestBehavior.AllowGet));
            }

            var result = _tblGateService.DeleteById(id, ref obj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.GateID.ToString(), obj.GateName, "tblGate", ConstField.ParkingCode, ActionConfigO.Delete);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #10
0
        private async Task <MessageReport> SendMessage(WM_Task task, List <string> users, string userid)
        {
            var result = new MessageReport(false, "error");

            try
            {
                //Người check hoàn thành
                var user = await GetUserById(userid);

                //Lấy Players
                var players = await _OS_PlayerService.GetPlayerIdsByUserIds(users);

                //Gửi
                var model = new OneSignalrMessage()
                {
                    Id          = "",
                    Title       = string.Format("Công việc: {0}", task.Title),
                    Description = string.Format("Công việc được check hoàn thành bởi {0}", user.Username),
                    UserIds     = "",
                    PlayerIds   = players.Select(n => n.PlayerId).ToArray(),
                    View        = "TaskPage"
                };

                result = await _OS_PlayerService.SendMessage(model);
            }
            catch (System.Exception ex)
            {
                result = new MessageReport(false, ex.Message);
            }

            return(result);
        }
        public MessageReport DeleteById(string id, ref tblCustomer obj)
        {
            var re = new MessageReport();

            re.Message   = "Error";
            re.isSuccess = false;

            try
            {
                obj = GetById(Guid.Parse(id));
                if (obj != null)
                {
                    _tblCustomerRepository.Delete(n => n.CustomerID.ToString() == id);

                    Save();

                    re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["DeleteSuccess"];
                    re.isSuccess = true;
                }
                else
                {
                    re.Message   = "Bản ghi không tồn tại";
                    re.isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                re.Message   = ex.Message;
                re.isSuccess = false;
            }

            return(re);
        }
        public async Task <MessageReport> RegisterReminder([FromForm] RegisterModel model)
        {
            //Khai báo
            var result = new MessageReport()
            {
                isSuccess = false,
                Message   = "error"
            };

            //Xử lý
            try
            {
                await ScheduleService.Register(model);

                result = new MessageReport()
                {
                    isSuccess = true,
                    Message   = "done"
                };
            }
            catch (Exception ex)
            {
                result = new MessageReport()
                {
                    isSuccess = false,
                    Message   = ex.Message
                };
            }

            //Trả về kết quả
            return(await Task.FromResult(result));
        }
        public ActionResult ReportMessage([FromBody] ReportCommand model)
        {
            if (_context.Users.Find(model.SenderId) == null)
            {
                return(NotFound("Could not find sender user with this id"));
            }

            if (_context.Messages.Find(model.ReportObjectId) == null)
            {
                return(NotFound("Could not find message with this id"));
            }

            var messageReport = new MessageReport();

            messageReport.Reason      = model.Reason;
            messageReport.Explanation = model.Explanation;
            messageReport.DateTime    = DateTime.Now.AddHours(2);
            messageReport.MessageId   = model.ReportObjectId;
            messageReport.SenderId    = model.SenderId;

            try
            {
                _context.MessageReports.Add(messageReport);
                _context.SaveChanges();
                return(Ok());
            }
            catch (Exception)
            {
                return(BadRequest("An error occured while trying to add message report."));
            }
        }
        public MessageReport DeleteById(string id, ref BM_Apartment_Member obj)
        {
            var re = new MessageReport();

            re.Message   = "Error";
            re.isSuccess = false;

            try
            {
                obj = GetById(Guid.Parse(id));
                if (obj != null)
                {
                    _BM_Apartment_MemberRepository.Delete(n => n.Id.ToString() == id);

                    Save();

                    re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["DeleteSuccess"];
                    re.isSuccess = true;
                }
                else
                {
                    re.Message   = FunctionHelper.GetLocalizeDictionary("Home", "notification")["record_does_not_exist"];
                    re.isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                re.Message   = ex.Message;
                re.isSuccess = false;
            }

            return(re);
        }
Exemple #15
0
        public async Task <MessageReport> Update(API_QRCodeCheckResponse model, string evenid)
        {
            var query = new StringBuilder();

            query.AppendLine("UPDATE tblEventPayment SET");
            query.AppendLine(string.Format(" PaymentStatus = {0} ", model.paymentStatus));
            query.AppendLine(string.Format(", isSuccessPay = {0} ", model.paymentStatus == 200 ? "1" : "0"));
            query.AppendLine(string.Format(", ResponseContentPay = '{0}' ", JsonConvert.SerializeObject(model)));
            query.AppendLine(string.Format("WHERE EventId = '{0}'", evenid));

            var result = new MessageReport(false, "error");

            try
            {
                Kztek.Data.Event.SqlHelper.ExcuteSQLEvent.Execute(query.ToString());

                result = new MessageReport(true, "success");
            }
            catch (Exception ex)
            {
                result = new MessageReport(false, ex.Message);
            }

            return(await Task.FromResult(result));
        }
Exemple #16
0
        public MessageReport Update(string _id, Answer obj)
        {
            var rp = new MessageReport();

            try
            {
                var query = Builders <Answer> .Filter.Eq(x => x._id, _id);

                var update = Builders <Answer> .Update.Set(x => x.Quesiton_id, obj.Quesiton_id)
                             .Set(x => x.AudioPath, obj.AudioPath)
                             .Set(x => x.Content, obj.Content)
                             .Set(x => x.CorrectIndex, obj.CorrectIndex)
                             .Set(x => x.CreatedDate, obj.CreatedDate)
                             .Set(x => x.ImagePath, obj.ImagePath)
                             .Set(x => x.IsActive, obj.IsActive);

                _IAnswerRepository.Update(query, update);
                rp.Success = true;
                rp.Message = "Cập nhật đáp án thành công!";
            }
            catch (Exception ex)
            {
                rp.Message = ex.Message;
            }
            return(rp);
        }
        public MessageReport DeleteById(string id)
        {
            var report = new MessageReport(false, "Có lỗi xảy ra");

            try
            {
                var objDelete = _MenuFunctionRepository.GetById(id);
                if (objDelete != null)
                {
                    objDelete.IsDeleted = true;
                    _MenuFunctionRepository.Update(objDelete);
                    Save();

                    //Update BreadCrumb
                    UpdateBreadCrumb(objDelete, "add");

                    report = new MessageReport(true, "Xóa thành công");
                }
            }
            catch (Exception ex)
            {
                report = new MessageReport(false, ex.Message);
            }

            _LogService.WriteLog(report, "MenuFunction", id, ActionConfig.Delete, user);

            return(report);
        }
        public JsonResult Delete(string id)
        {
            var obj = new tblCustomer();

            //Check tồn tại trong cardcustomer
            var existedInCard = _tblCardService.GetAllByCustomerId(id);

            if (existedInCard.Any())
            {
                var result1 = new MessageReport();
                result1.Message   = "Khách hàng đang sử dụng thẻ. Không thể xóa.";
                result1.isSuccess = false;
            }

            //Check tồn tại trong event
            //var existedInEvent = _PK_VehicleEventService.GetAllEventByCustomerId(id);
            //if (existedInEvent.Any())
            //{
            //    var result1 = new Result();
            //    result1.ErrorCode = 500;
            //    result1.Message = "Khách hàng đang tồn tại trong sự kiện. Không thể xóa.";
            //    result1.Success = false;
            //}

            var result = _tblCustomerService.DeleteById(id, ref obj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.CustomerID.ToString(), obj.CustomerCode, "tblCustomer", ConstField.ParkingCode, ActionConfigO.Delete);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public void HandledExceptionTest()
        {
            TestHelpers.StartApp();
            TestHelpers.LogHandledException();
            MessageReport messageReport = TestHelpers.DequeueMessageType(typeof(HandledException));

            Assert.IsNotNull(messageReport, "Expected a HandledException message");
        }
        public async Task <IActionResult> HomeCompleteTask(WM_TaskComplete model)
        {
            var result = new MessageReport(false, "Có lỗi xảy ra");
            var user   = await SessionCookieHelper.CurrentUser(this.HttpContext);

            model.UserId = user != null ? user.UserId : "";

            try
            {
                //Lấy task
                var objTask = await _WM_TaskService.GetById(model.TaskId);

                if (objTask == null)
                {
                    result = new MessageReport(false, "Công việc của bạn không tồn tại");
                    return(Json(result));
                }

                //Task user
                var userTask = await _WM_TaskService.GetByTaskId_UserId(model.TaskId, model.UserId);

                if (userTask == null)
                {
                    result = new MessageReport(false, "Công việc của bạn không tồn tại");
                    return(Json(result));
                }

                //Check công việc hoàn thành
                userTask.IsCompleted   = true;
                userTask.DateCompleted = DateTime.Now;
                userTask.IsOnScheduled = true;

                if (userTask.DateCompleted > objTask.DateEnd)
                {
                    userTask.IsOnScheduled = false;
                }

                result = await _WM_TaskService.UpdateUserTask(userTask);

                if (result.isSuccess)
                {
                    var userTasks = await _WM_TaskService.GetUserTasksByTaskId(objTask.Id);

                    var userIds = userTasks.Select(n => n.UserId).ToList();
                    userIds.Add(objTask.UserCreatedId);

                    SendMessageComplete(objTask, userIds, model.UserId);

                    RemoveSchedule(objTask);
                }
            }
            catch (System.Exception ex)
            {
                result = new MessageReport(false, ex.Message);
            }

            return(Json(result));
        }
        public async Task <MessageReport> User_Login([FromBody] API_User_Login model)
        {
            var result = new MessageReport(false, "Có lỗi xảy ra");

            try
            {
                //Kiểm tra đúng hệ thống
                //if (model.KeyPass != ApiConfig.Key_System)
                //{
                //    result = new MessageReport(false, "Kết nối không hợp lệ");
                //    return await Task.FromResult(result);
                //}

                //Kiểm tra user tồn tại
                var user = await Task.FromResult(_UserService.GetByUserName(model.Username));

                if (user == null)
                {
                    result = new MessageReport(false, "Tài khoản không tồn tại");
                    return(await Task.FromResult(result));
                }

                //Kiểm tra khóa
                if (user.Active == false)
                {
                    result = new MessageReport(false, "Tài khoản bị khóa");
                    return(await Task.FromResult(result));
                }

                //Kiểm tra mk
                var pass = model.Password.PasswordHashed(user.PasswordSalat);
                if (user.Password != pass)
                {
                    result = new MessageReport(false, "Mật khẩu không khớp");
                    return(await Task.FromResult(result));
                }

                //Gán lại
                var cus = new API_User()
                {
                    UserId   = user.Id,
                    Username = user.Username,
                    Avatar   = user.UserAvatar ?? "",
                    Name     = user.Name
                };

                var token = ApiHelper.GenerateJSON_MobileToken(user.Id);

                result = new MessageReport(true, token);
            }
            catch (Exception ex)
            {
                result = new MessageReport(false, ex.Message);
            }


            return(await Task.FromResult(result));
        }
Exemple #22
0
        public JsonResult DeleteEventPRIDE(string id)
        {
            var result = new MessageReport(false, "Có lỗi xảy ra");

            if (!string.IsNullOrEmpty(id))
            {
                var obj = new tblActiveCard();

                var activecard = _tblActiveCardService.GetById(id);

                if (activecard != null)
                {
                    //đếm số thẻ trong hóa đơn
                    var count = _tblActiveCardService.GetCountByOrderId(activecard.OrderId);

                    var card = _tblCardService.GetByCardNumber(activecard.CardNumber);
                    if (card != null)
                    {
                        if (Convert.ToDateTime(card.ExpireDate).Date == Convert.ToDateTime(activecard.NewExpireDate).Date)
                        {
                            if (count > 1)
                            {
                                var order = _OrderActiveCardService.GetById(activecard.OrderId);
                                if (order != null)
                                {
                                    order.Price = order.Price - activecard.FeeLevel;
                                    _OrderActiveCardService.Update(order);
                                }
                            }
                            else if (count == 1)
                            {
                                _OrderActiveCardService.DeleteById(activecard.OrderId);
                            }

                            card.ExpireDate = activecard.OldExpireDate;
                            _tblCardService.Update(card);
                            result = _tblActiveCardService.DeleteById(id);
                        }
                        else
                        {
                            result = new MessageReport(false, "Không thể xóa");
                        }
                    }
                }

                if (result.isSuccess)
                {
                    WriteLog.Write(result, GetCurrentUser.GetUser(), id, "", "tblActiveCard", ConstField.ParkingCode, ActionConfigO.Delete);
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("", JsonRequestBehavior.AllowGet));
            }
        }
        public async Task <MessageReport> CheckIn()
        {
            var report = new MessageReport()
            {
                isSuccess = false
            };
            tblCardEvent postbackEvent = null;
            string       msg           = "";

            try
            {
                var _API_EventInOUt = new API_EventInOut()
                {
                    CardNumber = HttpContext.Current.Request.Params["CardNumber"],
                    UserId     = HttpContext.Current.Request.Params["UserId"],
                    LaneId     = HttpContext.Current.Request.Params["LaneId"],
                };

                _API_EventInOUt.CardNumber = ConvertCard(_API_EventInOUt.CardNumber);

                Image imageData      = null;
                var   httpPostedFile = HttpContext.Current.Request.Files["file"];
                imageData = Image.FromStream(httpPostedFile.InputStream);

                //using (var ms = new MemoryStream())
                //{
                //    httpPostedFile.InputStream.CopyTo(ms);
                //    imageData = new Bitmap(ms);
                //}

                ProcessCardEventIn(_API_EventInOUt, imageData, ref postbackEvent, ref msg);
                if (postbackEvent != null)
                {
                    if (!string.IsNullOrWhiteSpace(postbackEvent.PicDirIn))
                    {
                        postbackEvent.PicDirIn = postbackEvent.PicDirIn.Replace($@"\\{Environment.MachineName}", "").Replace(@"\", @"/");
                    }

                    report.isSuccess = true;
                    report.Message   = JsonConvert.SerializeObject(postbackEvent, new JsonSerializerSettings
                    {
                        DateTimeZoneHandling = DateTimeZoneHandling.Local
                    });
                }
                else
                {
                    report.Message = msg;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(await Task.FromResult(report));
        }
Exemple #24
0
        public async Task <MessageReport> CompleteTask(WM_TaskComplete model)
        {
            var result = new MessageReport(false, "Có lỗi xảy ra");

            try
            {
                //Lấy task
                var objTask = await GetTaskById(model.TaskId);

                if (objTask == null)
                {
                    result = new MessageReport(false, "Công việc của bạn không tồn tại");
                    return(result);
                }

                //Task user
                var userTask = await GetTaskUserByTaskId_UserId(model.TaskId, model.UserId);

                if (userTask == null)
                {
                    result = new MessageReport(false, "Công việc của bạn không tồn tại");
                    return(result);
                }

                //Check công việc hoàn thành
                userTask.IsCompleted   = true;
                userTask.DateCompleted = DateTime.Now;
                userTask.IsOnScheduled = true;

                if (userTask.DateCompleted > objTask.DateEnd)
                {
                    userTask.IsOnScheduled = false;
                }

                result = await UpdateUserTask(userTask);

                if (result.isSuccess)
                {
                    //danh sách
                    var userTasks = await GetTaskUsersByTaskId(objTask.Id);

                    var user = userTasks.Select(n => n.UserId).ToList();
                    user.Add(objTask.UserCreatedId);

                    SendMessage(objTask, user, model.UserId);

                    RemoveSchedule(objTask);
                }
            }
            catch (System.Exception ex)
            {
                result = new MessageReport(false, ex.Message);
            }

            return(result);
        }
        /// <summary>
        /// Lưu lại sự kiện locker
        /// </summary>
        /// <param name="model"></param>
        /// <param name="actionV"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public JsonResult SaveEvent(tblLocker model, string actionV, string message)
        {
            var result = new MessageReport(false, "Có lỗi xảy ra");

            //Lưu tblLockerProcess

            result = _tblLockerProcessService.CreateSql(model, actionV, message, "1");

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #26
0
        public async Task <MessageReport> UpdateInfo(UserUpdateModel model)
        {
            var result = new MessageReport(false, "Có lỗi xảy ra");

            try
            {
                //Kiểm tra tài khoản tồn tại
                var user = await GetById(model.UserId);

                if (user == null)
                {
                    result = new MessageReport(false, "Tài khoản không tồn tại");
                    return(await Task.FromResult(result));
                }

                //Gán mới:
                user.Name = model.Name;

                //
                if (model.FileUpload != null && model.FileUpload.ContentType != null)
                {
                    var filePath = Path.Combine(Directory.GetCurrentDirectory(), await AppSettingHelper.GetStringFromAppSetting("FileUpload:UserFolder"));
                    var res      = await UploadHelper.UploadFile(model.FileUpload, filePath);

                    if (res.isSuccess == false)
                    {
                        return(await Task.FromResult(res));
                    }

                    var userfolder = await AppSettingHelper.GetStringFromAppSetting("FileUpload:UserFolder");

                    user.Avatar = userfolder + user.Id + "/" + model.FileUpload.FileName;
                }

                var query = new StringBuilder();
                query.AppendLine("{");
                query.AppendLine("'_id': { '$eq': '" + model.UserId + "' }");
                query.AppendLine("}");

                result = await _SY_UserRepository.Update(MongoHelper.ConvertQueryStringToDocument(query.ToString()), user);

                if (result.isSuccess)
                {
                    result.Message = JsonConvert.SerializeObject(user);
                }

                return(result);
            }
            catch (System.Exception ex)
            {
                result = new MessageReport(false, ex.Message);
            }

            return(await Task.FromResult(result));
        }
        public HttpResponseMessage ExtendCardByOrder(HttpRequestMessage request, PMC_CustomerOrder model)
        {
            var result = new MessageReport(false, "Có lỗi xảy ra");

            //Check Auth
            var objAuth = _API_AuthService.GetDefault();

            if (objAuth != null)
            {
                if (objAuth.AccessToken != model.AccessToken)
                {
                    result = new MessageReport(false, "Token không khớp");

                    //Trả lại response
                    return(CreateHttpResponse(request, () =>
                    {
                        var response = request.CreateResponse(result.isSuccess ? HttpStatusCode.OK : HttpStatusCode.BadRequest, result);
                        return response;
                    }));
                }
            }

            //Xử lý logic gia hạn
            var obj = _tblCardService.GetByCardNumber(model.CardNumber);

            if (obj != null)
            {
                string dateextend = Convert.ToDateTime(obj.ExpireDate).AddDays(model.DayExtend).ToString("MM/dd/yyyy");
                var    money      = model.Money.ToString().Replace(".", "").Replace(",", "");

                var isSuccess = _tblCardService.AddCardExpireByListCardNumber("'" + model.CardNumber + "'", int.Parse(money), dateextend, "Từ APP", false);

                if (isSuccess)
                {
                    //result = new MessageReport(true, FunctionHelper.GetLocalizeDictionary("Home", "notification")["updateSuccess"]);
                    result = new MessageReport(true, "Gia hạn thành công");
                }
                else
                {
                    //result = new MessageReport(false, FunctionHelper.GetLocalizeDictionary("Home", "notification")["updateFailed"]);
                    result = new MessageReport(false, "Gia hạn thất bại");
                }
            }
            else
            {
                result = new MessageReport(false, "Thẻ không tồn tại");
            }

            //Trả lại response
            return(CreateHttpResponse(request, () =>
            {
                var response = request.CreateResponse(result.isSuccess ? HttpStatusCode.OK : HttpStatusCode.BadRequest, result);
                return response;
            }));
        }
        public JsonResult RemoveRegisterLockerWithCardNumber(string lockerid, string cardnumber)
        {
            var result = new MessageReport(false, "Có lỗi xảy ra");

            try
            {
                var objLocker = _tblLockerService.GetById(lockerid);
                if (objLocker != null)
                {
                    //var objController = _tblLockerControllerService.GetById(objLocker.ControllerID);
                    //if (objController != null)
                    //{
                    //    var objLine = _tblLockerLineService.GetById(objController.LineID);
                    //    if (objLine != null)
                    //    {
                    //        var objSelfHost = _tblLockerSelfHostService.GetByPCID(objLine.PCID);
                    //        if (objSelfHost != null)
                    //        {
                    //            var uri = string.Format("http://{0}:8081/api/register/deletebycontroller", objSelfHost.Address);

                    //            var map = new Employee()
                    //            {
                    //                CardNumber = objLocker.CardNumber,
                    //                AccessLevelID = objLocker.ReaderIndex.ToString(),
                    //                ControllerIDs = objLocker.ControllerID,
                    //                UserID = "",
                    //                UserIDofFinger = 0,
                    //                ExpireDate = "20991231"
                    //            };

                    //            result = ApiService<Employee>.PostObjReturnObj(uri, map);
                    //        }
                    //    }
                    //}

                    //if (result.isSuccess)
                    //{
                    objLocker.LockerType = "0"; //Chưa sử dụng
                    objLocker.CardNumber = "";
                    objLocker.CardNo     = "";

                    result = _tblLockerService.Update(objLocker);

                    ////Lưu sự kiện vào tblLockerProcess

                    //}
                }
            }
            catch (Exception ex)
            {
                result = new MessageReport(false, ex.Message);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public JsonResult MutilDelete(string lstId)
        {
            bool isSucccess = _tblCustomerGroupService.DeleteByIds(lstId);

            if (isSucccess)
            {
                MessageReport report = new MessageReport(true, "Xóa thành công");
                WriteLog.Write(report, GetCurrentUser.GetUser(), lstId, lstId, "tblCustomerGroup", ConstField.AccessControlCode, ActionConfigO.Delete);
            }
            return(Json(isSucccess, JsonRequestBehavior.AllowGet));
        }
Exemple #30
0
        public void LogNetworkRequestTest()
        {
            APM.interval = 1;
            TestHelpers.StartApp();
            Assert.IsNull(TestHelpers.TestNetwork().AppLoadResponse);
            Assert.IsTrue(APM.enabled);
            string method       = "GET";
            string uriString    = "http://www.mrscritter.com";
            long   latency      = 4000;
            long   bytesRead    = 10000;
            long   bytesSent    = 10000;
            long   responseCode = 200;

            Crittercism.LogNetworkRequest(
                method,
                uriString,
                latency,
                bytesRead,
                bytesSent,
                (HttpStatusCode)responseCode,
                WebExceptionStatus.Success);
            Trace.WriteLine("Crittercism.LogNetworkRequest returned");
            Trace.WriteLine("APM.enabled == " + APM.enabled);
            MessageReport messageReport = TestHelpers.DequeueMessageType(typeof(APMReport));

            if (messageReport != null)
            {
                Trace.WriteLine("We found an APMReport (YAY)");
            }
            else
            {
                Trace.WriteLine("We didn't find an APMReport (BOO)");
                Trace.WriteLine("APM.enabled == " + APM.enabled);
                Assert.IsNotNull(messageReport, "Expected an APMReport message");
            };
            String asJson = JsonConvert.SerializeObject(messageReport);

            Trace.WriteLine("asJson == " + asJson);
            string[] jsonStrings = new string[] {
                "\"d\":",
                "\"GET\"",
                "\"http://www.mrscritter.com\"",
                "4000",
                "10000",
                "200"
            };
            foreach (String jsonFragment in jsonStrings)
            {
                Trace.WriteLine("jsonFragment == " + jsonFragment);
                Trace.WriteLine("asJson.Contains(jsonFragment) == " + asJson.Contains(jsonFragment));
                Assert.IsTrue(asJson.Contains(jsonFragment));
            }
            ;
        }