public ComplainSolution(ComplainDTO complain)
 {
     ComplainSolutionViewModel.Errors = 0;
     InitializeComponent();
     Messenger.Default.Send <ComplainDTO>(complain);
     Messenger.Reset();
 }
Example #2
0
        public string InsertOrUpdate(ComplainDTO complain)
        {
            try
            {
                var validate = Validate(complain);
                if (!string.IsNullOrEmpty(validate))
                {
                    return(validate);
                }

                if (ObjectExists(complain))
                {
                    return(GenericMessages.DatabaseErrorRecordAlreadyExists);
                }

                complain.Synced = false;
                _complainRepository.InsertUpdate(complain);
                _unitOfWork.Commit();
                return(string.Empty);
            }
            catch (DbUpdateConcurrencyException)
            {
                return(GenericMessages.DatabaseConcurrencyIssue);
            }
            catch (Exception exception)
            {
                return(exception.Message);
            }
        }
Example #3
0
        public bool DeleteComplaines(IUnitOfWork sourceUnitOfWork, IUnitOfWork destinationUnitOfWork)
        {
            List <ComplainDTO> addressDtos = sourceUnitOfWork.Repository <ComplainDTO>()
                                             .Query()
                                             .Get(-1)
                                             .ToList();

            foreach (ComplainDTO source in addressDtos)
            {
                ComplainDTO adr1        = source;
                var         destination =
                    destinationUnitOfWork.Repository <ComplainDTO>()
                    .Query()
                    .Filter(i => i.RowGuid == adr1.RowGuid)
                    .Get(-1)//don't use .Get() to make sure both sides of data are disabled
                    .FirstOrDefault();

                if (destination != null)
                {
                    sourceUnitOfWork.Repository <ComplainDTO>().Delete(source.Id);
                    destinationUnitOfWork.Repository <ComplainDTO>().Delete(destination.Id);

                    sourceUnitOfWork.Commit();
                    destinationUnitOfWork.Commit();
                }
            }

            return(true);
        }
Example #4
0
        public string Disable(ComplainDTO complain)
        {
            if (complain == null)
            {
                return(GenericMessages.ObjectIsNull);
            }

            string stat;
            var    iDbContext = DbContextUtil.GetDbContextInstance();

            try
            {
                _complainRepository.Update(complain);
                _unitOfWork.Commit();
                stat = string.Empty;
            }
            catch (Exception exception)
            {
                stat = exception.Message;
            }
            finally
            {
                iDbContext.Dispose();
            }
            return(stat);
        }
Example #5
0
        public ActionResult Confirm(ComplainDTO complainDTO)
        {
            try
            {
                var empService = new EmployeeService(false, true);

                var cri = new SearchCriteria <EmployeeDTO>();
                cri.FiList.Add(e => e.Id == complainDTO.EmployeeId);
                var emp = empService.GetAll(cri).FirstOrDefault();

                if (emp != null)
                {
                    var compDTO = emp.Complains.FirstOrDefault(c => c.Id == complainDTO.Id);

                    if (compDTO != null)
                    {
                        compDTO.Confirmation     = complainDTO.Confirmation;
                        compDTO.ConfirmationDate = complainDTO.ConfirmationDate;
                        compDTO.Status           = ComplainStatusTypes.Confirmed;

                        emp.CurrentStatus = ProcessStatusTypes.OnGoodCondition;
                        empService.InsertOrUpdate(emp);
                        empService.Dispose();
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #6
0
        public string Validate(ComplainDTO complain)
        {
            if (null == complain)
            {
                return(GenericMessages.ObjectIsNull);
            }

            if (String.IsNullOrEmpty(complain.Complain))
            {
                return(complain.Complain + " " + GenericMessages.StringIsNullOrEmpty);
            }


            return(string.Empty);
        }
Example #7
0
        public ActionResult Delete(ComplainDTO complainDTO)
        {
            try
            {
                var compService = new ComplainService(false);
                compService.Delete(complainDTO.Id.ToString());
                compService.Dispose();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View(complainDTO));
            }
        }
Example #8
0
        public ActionResult Details(string compId)
        {
            int complainId  = EncryptionUtility.Hash64Decode(compId);
            var complainDTO = new ComplainDTO
            {
                Employee = new EmployeeDTO()
            };

            if (complainId != 0)
            {
                complainDTO = new ComplainService(true)
                              .GetAll()
                              .ToList()
                              .FirstOrDefault(v => v.Id == complainId);
            }
            return(View(complainDTO));
        }
Example #9
0
        private void ExecuteAddNewComplainViewCommand()
        {
            SelectedComplain = new ComplainDTO
            {
                AgencyId     = Singleton.Agency.Id,
                ComplainDate = DateTime.Now,
                Priority     = ComplainProrityTypes.Medium,
                Type         = ComplainTypes.DidNotCall,
                Complain     = EnumUtil.GetEnumDesc(ComplainTypes.DidNotCall),
                Status       = ComplainStatusTypes.Opened
            };

            SelectedComplainRemark = new ComplainRemarkDTO
            {
                AgencyId = Singleton.Agency.Id,
                Complain = SelectedComplain
            };
        }
Example #10
0
        public ActionResult ComplainListProvide(ComplainDTO complainDTO)
        {
            if (!base.HasPermission("Complain", PermissionOperate.manager))
            {
                return(null);
            }

            OceanDynamicList <object> list = _complainService.GetPageDynamicList(PageIndex, PageSize, complainDTO);

            if (list != null)
            {
                return(Content(list.ToJson(), "text/javascript"));
            }
            else
            {
                return(Content("{\"rows\":[],\"total\":0}", "text/javascript"));
            }
        }
Example #11
0
        public ActionResult CloseComplain(ComplainDTO complainDTO)
        {
            try
            {
                var complainService = new ComplainService(false);
                var compDTO         = complainService.Find(complainDTO.Id.ToString());
                compDTO.FinalSolution     = complainDTO.FinalSolution;
                compDTO.FinalSolutionDate = complainDTO.FinalSolutionDate;
                compDTO.Status            = ComplainStatusTypes.Closed;
                complainService.InsertOrUpdate(compDTO);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #12
0
        public ActionResult Confirm(string compId)
        {
            int complainId  = EncryptionUtility.Hash64Decode(compId);
            var complainDTO = new ComplainDTO
            {
                Employee = new EmployeeDTO()
            };

            if (complainId != 0)
            {
                complainDTO = new ComplainService(true)
                              .GetAll()
                              .ToList()
                              .FirstOrDefault(v => v.Id == complainId);
                if (complainDTO != null)
                {
                    complainDTO.ConfirmationDate = DateTime.Now;
                }
            }
            return(View(complainDTO));
        }
Example #13
0
        public bool ObjectExists(ComplainDTO complain)
        {
            //var objectExists = false;
            //var iDbContext = DbContextUtil.GetDbContextInstance();
            //try
            //{
            //    var catRepository = new Repository<ComplainDTO>(iDbContext);
            //    var catExists = catRepository.Query()
            //        .Filter(bp => bp.FirstName == complain.FirstName && bp.Id != complain.Id && bp.Type == complain.Type)
            //        .Get()
            //        .FirstOrDefault();
            //    if (catExists != null)
            //        objectExists = true;
            //}
            //finally
            //{
            //    iDbContext.Dispose();
            //}

            //return objectExists;
            return(false);
        }
Example #14
0
        public ActionResult ReOpen(string compId)
        {
            int complainId  = EncryptionUtility.Hash64Decode(compId);
            var complainDTO = new ComplainDTO
            {
                AgencyId = Singleton.Agency.Id,
                Employee = new EmployeeDTO()
            };

            if (complainId != 0)
            {
                complainDTO = new ComplainService(true)
                              .GetAll()
                              .ToList()
                              .FirstOrDefault(v => v.Id == complainId);
                if (complainDTO != null)
                {
                    complainDTO.ReOpeningDate = DateTime.Now;
                }
            }
            return(View(complainDTO));
        }
        public async Task <ActionResult> Activity(string com_no, string groupid)
        {
            if (_UtilitySession.Session != null)
            {
                if (com_no == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ComplainDTO _complaint = new ComplainDTO();
                    ViewBag.Name = _UtilitySession.Session.user.name;
                    string User_id = _UtilitySession.Session.user.id;
                    _complaint = await Task.Run(() => _Repository.getComplainActivityDetails(com_no));

                    return(View(_complaint));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
        public async Task <ActionResult> Activity(string is_solved, string com_no, string techproblem, string techsolution, string remarks, string reason)
        {
            if (_UtilitySession.Session != null)
            {
                if (com_no == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ComplainDTO _complaint = new ComplainDTO();
                    ViewBag.Name = _UtilitySession.Session.user.name;
                    string User_id = _UtilitySession.Session.user.id;
                    var    sx      = await Task.Run(() => _Repository.SubmitComplainActivity(is_solved, com_no, techproblem, techsolution, remarks, reason));

                    return(View(_complaint));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Example #17
0
        public ActionResult Create(ComplainDTO complainDTO)
        {
            //try{}catch{}
            if (ModelState.IsValid)
            {
                if (complainDTO.EmployeeId == 0)
                {
                    return(RedirectToAction("Create"));
                }

                var empService = new EmployeeService();
                var emp        = empService.Find(complainDTO.EmployeeId.ToString());
                emp.Complains.Add(complainDTO);
                emp.CurrentComplain = complainDTO;
                //emp.CurrentStatus=ProcessStatusTypes.WithComplain;
                empService.InsertOrUpdate(emp);
                empService.Dispose();

                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return(View(complainDTO));
        }
Example #18
0
        public ActionResult ComplainListProvide(ComplainDTO complainDTO)
        {
            MpUserID = new Guid("E8325C13-9C76-4B70-911E-57395A2F4D69");
            MpUser mpUser = _mpUserService.GetById(MpUserID);

            if (mpUser == null || mpUser.IsAuth != 1)
            {
                return(Json(new { message = "您没有权限,请先申请成为业务员!" }));
            }
            complainDTO.MpUserId = MpUserID;
            //IList<VehicleLicense> vehicleList = _vehicleLicenseService.GetList("from VehicleLicense where MpUserId = '" + mpUser.Id + "'");
            OceanDynamicList <object> complainList = _complainService.GetPageDynamicList(PageIndex, PageSize, complainDTO, 0);

            //ViewBag.VehicleList = new JavaScriptSerializer().Serialize(Json(vehicleList).Data); //Json(vehicleList, JsonRequestBehavior.AllowGet);
            //return View(vehicleList);
            if (complainList != null)
            {
                return(Content(complainList.ToJson(), "text/javascript"));
            }
            else
            {
                return(Content("{\"rows\":[],\"total\":0}", "text/javascript"));
            }
        }
Example #19
0
        public OceanDynamicList <object> GetPageDynamicList(int pageIndex, int pageSize, ComplainDTO complainDTO)
        {
            string condition = "";
            Dictionary <string, object> parms = new Dictionary <string, object>();

            if (!string.IsNullOrEmpty(complainDTO.Name))
            {
                parms.Add("Name", complainDTO.Name);
                if (!string.IsNullOrEmpty(condition))
                {
                    condition += " and ";
                }
                else
                {
                    condition += " where ";
                }
                condition += "f.Name=@Name";
            }
            if (!string.IsNullOrEmpty(complainDTO.Phone))
            {
                parms.Add("Phone", complainDTO.Phone);
                if (!string.IsNullOrEmpty(condition))
                {
                    condition += " and ";
                }
                else
                {
                    condition += " where ";
                }
                condition += "Phone like '%'+@Phone+'%'";
            }

            if (!string.IsNullOrEmpty(complainDTO.ContactName))
            {
                parms.Add("ContactName", complainDTO.ContactName);
                if (!string.IsNullOrEmpty(condition))
                {
                    condition += " and ";
                }
                else
                {
                    condition += " where ";
                }
                condition += "ContactName like '%'+@ContactName+'%'";
            }
            if (!string.IsNullOrEmpty(complainDTO.ContactPhone))
            {
                parms.Add("ContactPhone", complainDTO.ContactPhone);
                if (!string.IsNullOrEmpty(condition))
                {
                    condition += " and ";
                }
                else
                {
                    condition += " where ";
                }
                condition += "ContactPhone like '%'+@ContactPhone+'%'";
            }
            if (complainDTO.StartDate.HasValue)
            {
                parms.Add("StartDate", complainDTO.StartDate);
                if (!string.IsNullOrEmpty(condition))
                {
                    condition += " and ";
                }
                else
                {
                    condition += " where ";
                }
                condition += "f.CreateDate >= @StartDate";
            }
            if (complainDTO.EndDate.HasValue)
            {
                parms.Add("EndDate", complainDTO.EndDate);
                if (!string.IsNullOrEmpty(condition))
                {
                    condition += " and ";
                }
                else
                {
                    condition += " where ";
                }
                condition += "f.CreateDate <= @EndDate";
            }

            return(this.GetDynamicList("SELECT f.Id, f.Name,f.Phone,f.ContactName,f.ContactPhone,f.ComplainContent,f.ProcessStatus,f.ProcessResult,f.ProcessDate,f.CreateDate FROM Complain f " + condition + " order by f.CreateDate desc", pageIndex, pageSize, parms));
        }
Example #20
0
        public bool SyncComplains(IUnitOfWork sourceUnitOfWork,
                                  IUnitOfWork destinationUnitOfWork)
        {
            Expression <Func <ComplainDTO, bool> > filter =
                a => !a.Synced && a.DateLastModified > LastServerSyncDate;

            if (!ToServerSyncing)
            {
                Expression <Func <ComplainDTO, bool> > filter2 =
                    a => a.Agency != null &&
                    a.Agency.RowGuid == Singleton.Agency.RowGuid;
                filter = filter.And(filter2);
            }
            var sourceList = sourceUnitOfWork.Repository <ComplainDTO>().Query()
                             .Include(a => a.Employee, a => a.Agency)
                             .Filter(filter)
                             .Get(1)
                             .ToList();

            var destLocalAgencies =
                destinationUnitOfWork.Repository <AgencyDTO>().Query()
                .Filter(a => a.Id == Singleton.Agency.Id)
                .Get(1)
                .ToList();

            if (sourceList.Any())
            {
                _updatesFound = true;
                var destEmployees =
                    destinationUnitOfWork.Repository <EmployeeDTO>().Query()
                    .Filter(a => a.AgencyId == Singleton.Agency.Id)
                    .Get(1).ToList();

                var destList =
                    destinationUnitOfWork.Repository <ComplainDTO>().Query()
                    .Filter(a => a.AgencyId == Singleton.Agency.Id)
                    .Include(a => a.Employee)
                    .Get(1)
                    .ToList();

                foreach (var source in sourceList)
                {
                    var destination =
                        destList.FirstOrDefault(i => i.RowGuid == source.RowGuid);

                    //To Prevent ServerData Overriding
                    if (destination == null)
                    {
                        destination = new ComplainDTO();
                    }
                    else if (ToServerSyncing && !destination.Synced)
                    {
                        continue;
                    }
                    try
                    {
                        Mapper.Reset();
                        Mapper.CreateMap <ComplainDTO, ComplainDTO>()
                        .ForMember("Agency", option => option.Ignore())
                        .ForMember("AgencyId", option => option.Ignore())
                        .ForMember("Id", option => option.Ignore())
                        .ForMember("RowVersion", option => option.Ignore())
                        .ForMember("Employee", option => option.Ignore())
                        .ForMember("Synced", option => option.Ignore());

                        destination = Mapper.Map(source, destination);

                        destination.CreatedByUserId = GetDestCreatedModifiedByUserId(source.CreatedByUserId,
                                                                                     sourceUnitOfWork, destinationUnitOfWork);
                        destination.ModifiedByUserId = GetDestCreatedModifiedByUserId(source.ModifiedByUserId,
                                                                                      sourceUnitOfWork, destinationUnitOfWork);
                    }
                    catch (Exception ex)
                    {
                        LogUtil.LogError(ErrorSeverity.Critical, "SyncComplains Mapping",
                                         ex.Message + Environment.NewLine + ex.InnerException, UserName, Agency);
                    }
                    try
                    {
                        #region Foreign Keys

                        var agencyDTO =
                            destLocalAgencies.FirstOrDefault(
                                c => source.Agency != null && c.RowGuid == source.Agency.RowGuid);
                        {
                            destination.Agency   = agencyDTO;
                            destination.AgencyId = agencyDTO != null ? agencyDTO.Id : (int?)null;
                        }


                        var employeeDto =
                            destEmployees.FirstOrDefault(
                                c => source.Employee != null && c.RowGuid == source.Employee.RowGuid);
                        {
                            destination.Employee   = employeeDto;
                            destination.EmployeeId = employeeDto != null ? employeeDto.Id : 1;
                        }

                        #endregion

                        destination.Synced = true;
                        destinationUnitOfWork.Repository <ComplainDTO>()
                        .InsertUpdate(destination);
                    }
                    catch
                    {
                        _errorsFound = true;
                        LogUtil.LogError(ErrorSeverity.Critical, "SyncComplains Crud",
                                         "Problem On SyncComplains Crud Method", UserName, Agency);
                        return(false);
                    }
                }
                var changes = destinationUnitOfWork.Commit();
                if (changes < 0)
                {
                    _errorsFound = true;
                    LogUtil.LogError(ErrorSeverity.Critical, "SyncComplains Commit",
                                     "Problem Commiting SyncComplains Method", UserName, Agency);
                    return(false);
                }
            }
            return(true);
        }
Example #21
0
        public ActionResult Create(string empId, string searchText)
        {
            bool employeefound = false;
            var  complainDTO   = new ComplainDTO
            {
                AgencyId     = Singleton.Agency.Id,
                ComplainDate = DateTime.Now,
                Priority     = ComplainProrityTypes.Medium,
                Type         = ComplainTypes.StatusNotKnown
            };

            if (!string.IsNullOrEmpty(empId))
            {
                int employeeId = EncryptionUtility.Hash64Decode(empId);
                var employee   = new EmployeeService(true, true)
                                 .GetAll().ToList()
                                 .FirstOrDefault(v => v.Id == employeeId);
                employeefound = true;

                complainDTO.EmployeeId = employeeId;
                complainDTO.Employee   = employee;
                complainDTO.Complain   = "...";
            }
            else if (!string.IsNullOrEmpty(searchText))
            {
                var criteria = new SearchCriteria <EmployeeDTO>();
                if (!string.IsNullOrEmpty(searchText))
                {
                    criteria.FiList.Add(bp => bp.Visa != null &&
                                        bp.Visa.Sponsor != null &&
                                        bp.CurrentStatus == ProcessStatusTypes.OnGoodCondition &&
                                        (bp.FullName.ToLower().Contains(searchText.ToLower()) ||
                                         bp.PassportNumber.ToLower().Contains(searchText.ToLower()) ||
                                         bp.Visa.Sponsor.PassportNumber.ToLower().Contains(searchText.ToLower()) ||
                                         bp.Visa.Sponsor.FullName.ToLower().Contains(searchText.ToLower()) ||
                                         bp.MoreNotes.ToLower().Contains(searchText.ToLower())));
                }

                var employee = new EmployeeService(true, true)
                               .GetAll(criteria).ToList().FirstOrDefault();

                if (employee != null)
                {
                    employeefound          = true;
                    complainDTO.EmployeeId = employee.Id;
                    complainDTO.Employee   = employee;
                    complainDTO.Complain   = "...";
                }
            }



            if (Request.IsAjaxRequest())
            {
                if (!Request.IsAuthenticated)
                {
                    Redirect("~/Account/Login");
                }

                if (!employeefound)
                {
                    complainDTO.Complain = "No Employee/Visa is found, please try your search again...";
                }

                return(PartialView("_employeeVisaShortDetail", complainDTO));
            }

            return(View(complainDTO));
        }