Exemplo n.º 1
0
        public PointViewModel GetPoint(int id)
        {
            Point          point          = repository.GetItem(id);
            PointViewModel pointViewModel = _mapper.Map <PointViewModel>(point);

            return(pointViewModel);
        }
Exemplo n.º 2
0
        public IActionResult Edit(PointViewModel point)
        {
            point.UserId = _userManager.GetUserId(User);
            _pointsService.UpdatePoint(point);

            return(RedirectToAction("Manage", "Home"));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> SaveModify(PointViewModel model)
        {
            using (PointServiceClient client = new PointServiceClient())
            {
                MethodReturnResult <Point> result = await client.GetAsync(model.Key);

                if (result.Code == 0)
                {
                    result.Data.ActionName          = model.ActionName;
                    result.Data.CategoryName        = model.CategoryName;
                    result.Data.EquipmentCode       = model.EquipmentCode;
                    result.Data.MaterialCode        = model.MaterialCode;
                    result.Data.MaterialType        = model.MaterialType;
                    result.Data.ProductionLineCode  = model.ProductionLineCode;
                    result.Data.RouteEnterpriseName = model.RouteEnterpriseName;
                    result.Data.RouteName           = model.RouteName;
                    result.Data.RouteStepName       = model.RouteStepName;
                    result.Data.RouteOperationName  = model.RouteOperationName;
                    result.Data.SamplingPlanName    = model.SamplingPlanName;
                    result.Data.Status      = model.Status;
                    result.Data.Description = model.Description;
                    result.Data.Editor      = User.Identity.Name;
                    result.Data.EditTime    = DateTime.Now;
                    MethodReturnResult rst = await client.ModifyAsync(result.Data);

                    if (rst.Code == 0)
                    {
                        rst.Message = string.Format(EDCResources.StringResource.Point_SaveModify_Success
                                                    , model.GroupName);
                    }
                    return(Json(rst));
                }
                return(Json(result));
            }
        }
Exemplo n.º 4
0
        private List <EquipmentAndPointsViewModel> _retrievePointsStatus(Company company, string type, string roleType)
        {
            if (company == null)
            {
                return(new List <EquipmentAndPointsViewModel>());
            }

            // TO DO
            // Let's assume to build a table with a single point per row
            var equipList    = _buildingService.GetEquipmentByCompany(type, company);
            var viewModelMap = new Dictionary <string, EquipmentAndPointsViewModel>();

            foreach (var item in equipList)
            {
                PointRole pt = item.PointRoles.Items.FirstOrDefault(r => r.Type.Id == roleType);
                // For now let's filter out equipment without the requested pointrole.
                // Not sure if we need them or not
                if (pt != null)
                {
                    var model = new EquipmentAndPointsViewModel
                    {
                        EquipmentName = item.Name,
                        EquipmentId   = item.Id,
                        EquipmentType = item.Type.Id,
                    };
                    var list = new List <PointViewModel>();
                    var m    = new PointViewModel()
                    {
                        PointRole = pt.Type.Id, PointId = pt.Point.Id
                    };
                    list.Add(m);
                    model.PointsStatus = list;
                    viewModelMap.Add(model.PointsStatus.First().PointId, model);
                }
            }

            if (viewModelMap.Count == 0)
            {
                return(new List <EquipmentAndPointsViewModel>());
            }

            var pointsInfo = _buildingService.GetPointsSummary(viewModelMap.Keys, company);

            foreach (var item in pointsInfo)
            {
                if (viewModelMap.ContainsKey(item.Id) && viewModelMap[item.Id].PointsStatus.Any())
                {
                    viewModelMap[item.Id].PointsStatus.First().UoM = (item.Units == null) ? item.States.Id : item.Units.Id;
                    // At this point GetPointsSummary does not return the nested Newest field
                    // To be improved
                    if (item.SampleSummary.Newest != null)
                    {
                        viewModelMap[item.Id].PointsStatus.First().LastValue          = string.Format("{0:0.##}", item.SampleSummary.Newest.Value);
                        viewModelMap[item.Id].PointsStatus.First().TimeStampLastValue = item.SampleSummary.Newest.Timestamp;
                    }
                }
            }

            return(viewModelMap.Values.ToList());
        }
Exemplo n.º 5
0
        public static PointViewModel CreatePoint(this DesignerViewModel designer, Vector2 position)
        {
            var newPoint = new PointViewModel(Guid.NewGuid(), position);

            newPoint.AddTo(designer);
            return(newPoint);
        }
Exemplo n.º 6
0
        public ActionResult Edit(Guid id)
        {
            PointModel point = new PointService().GetPoint(id);

            PointViewModel viewModel = new PointViewModel
            {
                Id          = point.Id,
                Name        = point.Name,
                Address     = point.Address,
                PostalCode  = point.PostalCode,
                City        = point.City,
                Coordenate  = point.Coordenate,
                PhoneNumber = point.PhoneNumber,
                URL         = point.URL,
                SourceURL   = point.SourceURL,
                IsActive    = point.IsActive
            };

            if (point.Topics.Count > 0)
            {
                viewModel.SelectedTopicId = new string[point.Topics.Count];

                int i = 0;
                foreach (TopicModel item in point.Topics)
                {
                    viewModel.SelectedTopicId[i++] = item.Id.ToString();
                }
            }
            ViewBag.Topics = new MultiSelectList(new TopicService().GetActiveTopics(), "Id", "Name", viewModel.SelectedTopicId);
            ViewBag.City   = new SelectList(new CityService().GetCities(), "Id", "Name");

            return(View(viewModel));
        }
Exemplo n.º 7
0
        public DesignerViewModel(int width, int height)
        {
            Width           = width;
            Height          = height;
            Selection       = new SelectionViewModel(Guid.NewGuid(), Vector2.Zero, Vector2.Zero);
            CreateSelection = new SelectionViewModel(Guid.NewGuid(), Vector2.Zero, Vector2.Zero)
            {
                BorderColor = Color.Green
            };

            NewConnectionPath = new PathViewModel();
            MousePoint        = new PointViewModel(Guid.NewGuid(), Vector2.Zero)
            {
                IsShown = false
            };

            ResizeDirection = ResizeDirection.None;

            Interactor.AddPoint      += UserInteractionManager_AddPoint;
            Interactor.CreateAt      += UserInteractionManager_CreateAt;
            Interactor.DeleteAt      += UserInteractionManager_DeleteAt;
            Interactor.SelectAt      += UserInteractionManager_SelectAt;
            Interactor.MouseMoved    += UserInteractionManager_MouseMoved;
            Interactor.MouseReleased += UserInteractionManager_MouseReleased;

            Interactor.MouseClicked       += Interactor_MouseClicked;
            Interactor.MouseDoubleClicked += Interactor_MouseDoubleClicked;
            Interactor.KeyPressed         += Interactor_KeyPressed;
        }
Exemplo n.º 8
0
        public ActionResult Create(PointViewModel point)
        {
            point.UserId = _userManager.GetUserId(User);
            _pointsService.Create(point);

            return(RedirectToAction("Index", "Maps"));
        }
Exemplo n.º 9
0
        public ActionResult Create(FormCollection formCollection, PointViewModel vo)
        {
            if (ModelState.IsValid)
            {
                var entity = MappingManager.PointHistoryEntityMapping(vo);
                entity.CreatedUser = base.CurrentUser.CustomerId;
                entity.UpdatedUser = base.CurrentUser.CustomerId;
                entity.Status      = (int)DataStatus.Normal;
                using (var ts = new TransactionScope())
                {
                    entity = this._pointRepository.Insert(entity);

                    if (vo.Amount > 0)
                    {
                        _userService.AddPoint(vo.User_Id, (int)vo.Amount, base.CurrentUser.CustomerId);
                    }
                    else
                    {
                        _userService.SubPoint(vo.User_Id, (int)vo.Amount, base.CurrentUser.CustomerId);
                    }
                    ts.Complete();
                }

                return(RedirectToAction("Details", new { id = entity.Id }));
            }

            return(View(vo));
        }
Exemplo n.º 10
0
        public void ViewModelToModelTest()
        {
            var viewModel = new PointViewModel
            {
                Answer    = "a",
                Latitude  = 1.2,
                Longitude = 1.1,
                Message   = "b",
                Name      = "c",
                PointId   = Guid.NewGuid(),
                StageId   = Guid.NewGuid(),
                Type      = PointTypeViewModel.CheckPoint,
                Value     = 10
            };

            var result = _Sut.Map <Point>(viewModel);

            Assert.AreEqual(viewModel.Answer, result.Answer);
            Assert.AreEqual(viewModel.Latitude, result.Latitude);
            Assert.AreEqual(viewModel.Longitude, result.Longitude);
            Assert.AreEqual(viewModel.Message, result.Message);
            Assert.AreEqual(viewModel.Name, result.Name);
            Assert.AreEqual(viewModel.PointId, result.PointId);
            Assert.AreEqual(viewModel.StageId, result.StageId);
            Assert.AreEqual((int)viewModel.Type, (int)result.Type);
            Assert.AreEqual(viewModel.Value, result.Value);
        }
Exemplo n.º 11
0
        public async Task <ActionResult> About(PointViewModel model)
        {
            var points = await _pointService.GetListOfPointAsync(model.AddressLine);

            var addresses = _mapper.Map <List <PointViewModel> >(points);

            return(View(addresses));
        }
Exemplo n.º 12
0
 private void btnChooseTeam_Click(object sender, RoutedEventArgs e)
 {
     if (this.DataContext != null)
     {
         PointViewModel pvm = DataContext as PointViewModel;
         pvm.GetTeamToChoose();
     }
 }
Exemplo n.º 13
0
        public MainWindow()
        {
            InitializeComponent();
            PointViewModel pvm = new PointViewModel();

            this.DataContext = pvm;
            AddHotKey();
        }
Exemplo n.º 14
0
        public ActionResult DeletePoint(PointViewModel pointToAdd, string fileNameToDelete)
        {
            _polygonService.DeletePoint();
            var    points    = _polygonService.Points;
            string _fileName = _polygonPainter.DrawPolygonWhileCrating(points, fileNameToDelete);

            ViewBag.FileName = _fileName;
            return(PartialView("_PointList", _polygonService.Points));
        }
Exemplo n.º 15
0
        public ActionResult Create()
        {
            PointViewModel viewModel = new PointViewModel();

            ViewBag.Topics = new MultiSelectList(new TopicService().GetActiveTopics(), "Id", "Name");
            ViewBag.City   = new SelectList(new CityService().GetCities(), "Id", "Name");

            return(View());
        }
        public ViewResult Point(int id)
        {
            var model = new PointViewModel
            {
                Card       = _cardService.GetCard(id),
                PointValue = _pointService.GetCardPoint(id, _currentUserId)
            };

            return(View(model));
        }
        public CheckerElementViewModel(CheckerModel checkerModel, List <CheckerElementViewModel> emptyCheckerElementViewModels)
        {
            _checkerModel = checkerModel;
            _checkerModel.PositionChangedAction += PositionChangedAction;

            Side = checkerModel.Side;
            Type = checkerModel.Type;
            _pos = new PointViewModel(_checkerModel.Row, _checkerModel.Column);
            PossibleMovementElements = emptyCheckerElementViewModels.Where(x => _checkerModel.PossibleMovementElements.Any(y => x.Column == y.Column && x.Row == y.Row)).ToList();
        }
Exemplo n.º 18
0
        public PointViewModel UpdatePoint(int id, int pointId, PointViewModel point)
        {
            var dataPoint = _db.Points.Single(p => p.Id == pointId);

            dataPoint.Price       = point.Price;
            dataPoint.ArrivalTime = point.ArrivalTime;
            _db.SaveChanges();

            return(Map <PointViewModel>(dataPoint));
        }
Exemplo n.º 19
0
        public IActionResult AddScores(PointViewModel model)
        {
            var addCreditsParams = _mapper.Map <AddScoresParams>(model);

            _loyaltyService.AddScores(addCreditsParams);

            //TODO: (Murat) AddScores notifications should be clarified!
            //await _notificationManager.SendNotification(accessToken, model.UserId);

            return(Ok(true));
        }
Exemplo n.º 20
0
        protected void RemovePnt(PointViewModel pointToRemove)
        {
            var pn = pointToRemove.PntRc;

            if (_patternCerchio.PointList.Contains(pn))
            {
                _patternCerchio.PointList.Remove(pn);
            }

            OnPropertyChanged("PointList");
        }
        public GetPointUI()
        {
            InitializeComponent();

            _pointMonitor = new PointMonitor();
            var viewModel = new PointViewModel();

            viewModel.SelectedRowChanged += _pointMonitor.OnHighlightPoint;

            DataContext = viewModel;
        }
Exemplo n.º 22
0
        public EditPointWindow(PointViewModel point)
        {
            InitializeComponent();
            this.Point = point;
            if (point != null) {
                txtLatitude.Text = point.Latitude.ToString();
                txtLongitude.Text = point.Longitude.ToString();
            }

            Loaded += new RoutedEventHandler(EditPointWindow_Loaded);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Get ObjectData and PointCenter by Code
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public JsonResult GetShapes(string code)
        {
            var            shapes      = drawPolygonBo.GetObjectDataByCode(code);
            PointViewModel pointCenter = drawPolygonBo.GetPointCenterByCode(code);

            return(Json(new
            {
                shapes,
                pointCenter
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 24
0
 public static PointDto ToDto(PointViewModel pointViewModel)
 {
     return(new PointDto
     {
         Id = pointViewModel.Id,
         CreatorId = pointViewModel.CreatorId,
         Current = pointViewModel.Current,
         PointCoordinates = pointViewModel.PointCoordinates,
         PointName = pointViewModel.PointName,
         User = pointViewModel.User.ToDto()
     });
 }
Exemplo n.º 25
0
        public async Task <ActionResult> AddressList(PointViewModel model)
        {
            var points = await _pointService.GetListOfPointAsync(model.AddressLine);

            var addresses = _mapper.Map <List <PointViewModel> >(points);

            var entities = _mapper.Map <List <Point> >(addresses);

            entities.ForEach(e => _repository.Add(e));

            return(View(addresses));
        }
Exemplo n.º 26
0
        public async Task <PointUserViewModel> AddPoint(PointViewModel pointViewModel)
        {
            await _userRepository.AddPoint(pointViewModel.UserId, pointViewModel.Point);

            var user = await _userRepository.GetById(pointViewModel.UserId);

            return(new PointUserViewModel
            {
                Name = user.FirstName + user.LastName,
                Point = pointViewModel.Point
            });
        }
Exemplo n.º 27
0
        public ActionResult Create(PointViewModel point)
        {
            if (ModelState.IsValid)
            {
                PointModel model = new PointModel
                {
                    Id          = point.Id != Guid.Empty ? point.Id : Guid.NewGuid(),
                    Name        = point.Name,
                    Address     = point.Address,
                    PostalCode  = point.PostalCode,
                    City        = point.City,
                    Coordenate  = point.Coordenate,
                    PhoneNumber = point.PhoneNumber,
                    URL         = point.URL,
                    SourceURL   = point.SourceURL,
                    IsActive    = point.IsActive
                };

                if (point.SelectedTopicId != null && point.SelectedTopicId.Length > 0)
                {
                    model.Topics = new List <TopicModel>();
                    for (int i = 0; i < point.SelectedTopicId.Length; i++)
                    {
                        TopicModel temp = new TopicService().GetTopic(new Guid(point.SelectedTopicId[i].ToString()));
                        model.Topics.Add(temp);
                    }
                }

                #region Validate Model After Conversion from ViewModel
                try
                {
                    if (model.IsValid)
                    {
                        service.InsertPoint(model);
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError("", model.Error);
                    }
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", e.Message);
                }
                #endregion
            }

            ViewBag.Topics = new MultiSelectList(new TopicService().GetActiveTopics(), "Id", "Name");
            ViewBag.City   = new SelectList(new CityService().GetCities(), "Id", "Name");

            return(View(point));
        }
Exemplo n.º 28
0
        private static ListBoxItem FindSymmetryPoint(FrameworkElement frameworkElement)
        {
            var dic = ((MainWindow)Application.Current.MainWindow).dic;

            PointViewModel dot = (PointViewModel)(((ListBoxItem)frameworkElement).Content);

            DependencyObject t = frameworkElement;

            while (true)
            {
                t = VisualTreeHelper.GetParent(t);
                if (t is Teeth)
                {
                    break;
                }
            }

            int idx_me  = dic[((Teeth)t).Name];
            int idx_you = idx_me + (idx_me >= 0 && idx_me < 3 ? +3 : -3);

            var   parent   = VisualTreeHelper.GetParent(t);
            Teeth sysTeeth = new Teeth();;

            for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
            {
                if (VisualTreeHelper.GetChild(parent, i) is Teeth)
                {
                    sysTeeth = VisualTreeHelper.GetChild(parent, i) as Teeth;
                    var myKey = dic.FirstOrDefault(p => p.Value == idx_you).Key;
                    if (myKey == sysTeeth.Name)
                    {
                        break;
                    }
                }
            }

            ListBox lb = new ListBox();

            foreach (DependencyObject c in LogicalTreeHelper.GetChildren(sysTeeth))
            {
                foreach (var cc in LogicalTreeHelper.GetChildren(c))
                {
                    if (cc is ListBox)
                    {
                        lb = cc as ListBox;
                        break;
                    }
                }
            }

            return((ListBoxItem)(lb.ItemContainerGenerator.ContainerFromIndex(dot.S)));
        }
Exemplo n.º 29
0
        public ActionResult Edit(PointViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Convert to Point Model
                PointModel point = new PointModel
                {
                    Id          = model.Id,
                    Name        = model.Name,
                    Address     = model.Address,
                    PostalCode  = model.PostalCode,
                    City        = model.City,
                    Coordenate  = model.Coordenate,
                    PhoneNumber = model.PhoneNumber,
                    URL         = model.URL,
                    SourceURL   = model.SourceURL,
                    IsActive    = model.IsActive
                };

                // Get Topics
                if (model.SelectedTopicId.Length > 0)
                {
                    point.Topics = new List <TopicModel>();
                    for (int i = 0; i < model.SelectedTopicId.Length; i++)
                    {
                        TopicModel temp = new TopicService().GetTopic(new Guid(model.SelectedTopicId[i].ToString()));
                        point.Topics.Add(temp);
                    }
                }
                try
                {
                    if (point.IsValid)
                    {
                        service.UpdatePoint(point);
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError("", point.Error);
                    }
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", e.Message);
                }
            }

            ViewBag.Topics = new MultiSelectList(new TopicService().GetActiveTopics(), "Id", "Name", model.SelectedTopicId);
            ViewBag.City   = new SelectList(new CityService().GetCities(), "Id", "Name");

            return(View(model));
        }
Exemplo n.º 30
0
        public PointHistoryEntity PointHistoryEntityMapping(PointViewModel source)
        {
            if (source == null)
            {
                return(null);
            }

            var target = Mapper.Map <PointViewModel, PointHistoryEntity>(source);

            target.CreatedDate = DateTime.Now;
            target.UpdatedDate = DateTime.Now;

            return(PointHistoryEntityCheck(target));
        }
Exemplo n.º 31
0
 private void btnMakeFullScreen_Click(object sender, RoutedEventArgs e)
 {
     if (this.WindowState == WindowState.Maximized)
     {
         this.WindowState = WindowState.Normal;
         this.Left        = 0;
         this.Top         = 0;
         return;
     }
     if (this.DataContext != null)
     {
         PointViewModel pvm = this.DataContext as PointViewModel;
         pvm.MakeFullScreen();
     }
 }