예제 #1
0
        public ActionResult Mapping()
        {
            var histWells  = _client.GetHistWells();
            var pdgtmWells = _client.GetPdgtmWells().Select(w => w.Name).ToList();
            var histTags   = _client.GetNotMappedHistTags(histWells.FirstOrDefault());
            var pdgtmTags  = _client.GetNotMappedPdgtmTags(pdgtmWells.FirstOrDefault());
            var mapItems   = _client.GetMappings();

            var model = new MappingViewModel()
            {
                HistTags   = histTags,
                HistWells  = histWells,
                PdgtmTags  = pdgtmTags,
                PdgtmWells = pdgtmWells,
                MapItems   = mapItems
            };

            return(View(model));
        }
예제 #2
0
        private void OnContextDisposing(object sender, EventArgs e)
        {
            var context = (EditingContext)sender;

            Debug.Assert(_context == context, "incorrect context");

            if (_selectionContainer != null)
            {
                _selectionContainer.Dispose();
                _selectionContainer = null;
            }

            if (_viewModel != null)
            {
                _viewModel.Dispose();
                _viewModel = null;
            }

            context.Items.SetValue(new MappingDetailsInfo());
            context.Disposing -= OnContextDisposing;
        }
예제 #3
0
        public async Task <List <Slot> > AddSlotToHeight(List <Height> heights, MappingViewModel mvm, ApplicationDbContext db)
        {
            List <Slot> slots = new List <Slot>();

            foreach (Height h in heights)
            {
                for (int i = 0; i < mvm.bays.numberOfSlots; i++)
                {
                    Slot slot = new Slot {
                        Height = h, slotID = i + 1
                    };
                    if (ModelState.IsValid)
                    {
                        db.Slot.Add(slot);
                        await db.SaveChangesAsync();
                    }
                    slots.Add(slot);
                }
            }
            return(slots);
        }
예제 #4
0
        public async Task <ActionResult> BuildingDetail(int?id)
        {
            Building building;

            if (id == null)
            {
                return(RedirectToAction("SelectBuilding"));
            }
            building = await db.Building.FindAsync(id);

            List <MappingViewModel> mvmItems = new List <MappingViewModel>();
            List <Row> rows = db.Row.Where(r => r.BuildingID == id).ToList();

            for (int i = 0; i < rows.Count; i++)
            {
                MappingViewModel mapItem = new MappingViewModel {
                    building = building, row = rows[i]
                };
                mvmItems.Add(mapItem);
            }
            return(View(mvmItems));
        }
예제 #5
0
        public ActionResult ChangeInformation(string name, string surname)
        {
            var userId            = User.Identity.GetUserId();
            var customer          = _customerService.GetCustomerByIdentityUserId(userId);
            var cistomerViewModel = MappingViewModel.MapCustomerViewModel(customer);

            if (Request.HttpMethod == "POST")
            {
                if (name.Length <= 3)
                {
                    ModelState.AddModelError("name", "Please enter valid name");
                }
                if (surname.Length <= 3)
                {
                    ModelState.AddModelError("surname", "Please enter valid surname");
                }
                if (ModelState.IsValid)
                {
                    customer.Name    = name;
                    customer.Surname = surname;
                    _customerService.ChangePersonalInformation(customer);
                    SLogger.InfoToFile($"Customer {customer.Id} changed name to {name} {surname}");
                    var messageInfo = new MessageViewModel()
                    {
                        Status = "success",
                        Info   = "Changed information"
                    };
                    return(RedirectToAction("Index", messageInfo));
                }
                else
                {
                    return(View(cistomerViewModel));
                }
            }
            else
            {
                return(View(cistomerViewModel));
            }
        }
예제 #6
0
        public ActionResult ChangeDiscount(int id, int?maxDiscount, int?stepDiscount)
        {
            var customer          = _managerService.GetCustomerById(id);
            var customerViewModel = MappingViewModel.MapCustomerViewModel(customer);

            if (Request.HttpMethod == "POST")
            {
                if (maxDiscount == null)
                {
                    ModelState.AddModelError("maxDiscount", "Please enter max discount");
                }
                if (stepDiscount == null)
                {
                    ModelState.AddModelError("stepDiscount", "Please enter step discount");
                }
                if (ModelState.IsValid)
                {
                    customer.StepDiscount = stepDiscount.Value;
                    customer.MaxDiscount  = maxDiscount.Value;
                    _managerService.ChangeDiscountCustomer(customer);
                    SLogger.InfoToFile($"Manager change discount customer id: {customer.Id}");
                    var messageInfo = new MessageViewModel()
                    {
                        Status = "success",
                        Info   = $"Changed discount for {customer.Name}"
                    };
                    return(RedirectToAction("Index", messageInfo));
                }
                else
                {
                    return(View(customerViewModel));
                }
            }
            else
            {
                return(View(customerViewModel));
            }
        }
예제 #7
0
        public async Task <ActionResult> AddBays(int?id, MappingViewModel mvm)
        {
            if (id == null)
            {
                RedirectToAction("SelectBuilding");
            }
            Row row = db.Row.Find(id);

            row.numberOfBays = mvm.row.numberOfBays;
            List <Bay> bays = new List <Bay>();

            for (int i = 0; i < mvm.row.numberOfBays; i++)
            {
                Bay bay = new Bay {
                    bayNumber = i + 1, Row = row
                };
                if (ModelState.IsValid)
                {
                    db.Bay.Add(bay);
                    await db.SaveChangesAsync();
                }
            }
            return(RedirectToAction("BuildingDetail", new { id = row.BuildingID }));
        }
        private void Save(SaveEvent saveEvent)
        {
            WebResponse<MdmId> response = this.mappingService.CreateMapping(
                this.entityName,
                this.entityId,
                this.Mapping.Model());

            if (response.IsValid)
            {
                this.eventAggregator.Publish(new StatusEvent(Message.MappingAdded));
                this.eventAggregator.Publish(new MappingClonedEvent(this.originalEntityId, this.originalMappingId));
                this.Mapping = new MappingViewModel(this.eventAggregator);
                this.navigationService.NavigateMainBackWithStatus(new StatusEvent(Message.MappingAdded));
                return;
            }

            this.eventAggregator.Publish(
                new ErrorEvent(response.Fault != null ? response.Fault.Message : "Unkown Error"));
        }
예제 #9
0
        private IList <Required> ReturnRequired(IList <sp_GetMappingViewModelData_Result> lstMappingViewModel, MappingViewModel mappingViewModel, IList <tbl_Transactions> highLevelTransactions)
        {
            try
            {
                List <Required> rList = new List <Required>();
                Parallel.ForEach(highLevelTransactions, item =>
                {
                    Required r = new Required();

                    string txnID = item.HighLevelTxnID;
                    r.dtMappingTable.TableName = item.HighLevelTxnDesc;
                    r.dtTM.TableName           = item.HighLevelTxnDesc;
                    r = GenerateTransactionMatrix(lstMappingViewModel, r, txnID, mappingViewModel);
                    rList.Add(r);
                    //using (StreamWriter writer =
                    //                                new StreamWriter(@"D:\Temp\" + item.HighLevelTxnDesc + ".txt"))
                    //{
                    //    writer.Write("Done ");

                    //}
                });
                return(rList);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #10
0
        public async Task <string> GenerateTransactionMatrix(int daId)
        {
            try
            {
                IList <sp_GetMappingViewModelData_Result> lstMappingViewModel = new List <sp_GetMappingViewModelData_Result>();
                TransactionsManager transactions = new TransactionsManager();

                MappingViewModel mappingViewModel = new MappingViewModel();
                lstNegativeAttributeValues = mappingViewModel.GetNegativeAttributeValues(daId);

                lstMappingViewModel = mappingViewModel.GetMappedData(daId);

                var highLevelTransactions = transactions.GetAllTransactions(daId);

                ExcelCommonFunctions excelCommonFunctions = new ExcelCommonFunctions();

                IList <Required> rList    = ReturnRequired(lstMappingViewModel, mappingViewModel, highLevelTransactions);
                string           filePath = "";
                using (ExcelPackage objExcelPackage = new ExcelPackage())
                { // Format Excel Sheet
                    int i = 0;
                    foreach (var item in highLevelTransactions)
                    {
                        var dtMappingTable = from a in rList
                                             where a.dtMappingTable.TableName == item.HighLevelTxnDesc
                                             select a;

                        var dtTM = from a in rList
                                   where a.dtTM.TableName == item.HighLevelTxnDesc
                                   select a;

                        ExcelWorksheet ws = excelCommonFunctions.CreateSheet(objExcelPackage, item.HighLevelTxnDesc, i);

                        ws.Cells[1, 1].Value = "Transaction - " + item.HighLevelTxnDesc;

                        // Format Excel Sheet
                        ws.Cells[1, 1, 1, 7].Merge                     = true;                          //Merge columns start and end range
                        ws.Cells[1, 1, 1, 7].Style.Font.Bold           = true;                          //Font should be bold
                        ws.Cells[1, 1, 1, 7].Style.Font.Size           = 20;
                        ws.Cells[1, 1, 1, 7].Style.HorizontalAlignment = ExcelHorizontalAlignment.Left; // Alignment is center
                        ws.Cells[1, 1, 1, 7].Style.Fill.PatternType    = ExcelFillStyle.Solid;          // Border
                        ws.Cells[1, 1, 1, 7].Style.Fill.BackgroundColor.SetColor(Color.LightGray);      // Background Color

                        int colIndex = 1, rowIndex = 0;


                        excelCommonFunctions.CreateTableHeader(dtMappingTable.First().dtMappingTable, ws, ref colIndex, ref rowIndex, "tbl1");
                        excelCommonFunctions.AddRows(dtMappingTable.First().dtMappingTable, ws, ref colIndex, ref rowIndex);

                        excelCommonFunctions.CreateTableHeader(dtTM.First().dtTM, ws, ref colIndex, ref rowIndex, "tbl2");
                        excelCommonFunctions.AddRows(dtTM.First().dtTM, ws, ref colIndex, ref rowIndex);

                        //Format Excel Sheet
                        ws.View.ShowGridLines = false;
                        ws.View.ZoomScale     = 80;
                        ws.Cells.AutoFitColumns();


                        i++;
                    }
                    tbl_DesignAccelerator da        = new tbl_DesignAccelerator();
                    DAManager             daManager = new DAManager();

                    da = daManager.FindDA(daId);

                    filePath = excelCommonFunctions.SaveFile(objExcelPackage, da.daName, "", "Rule of N - Txn Matrix");
                }


                return(filePath);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #11
0
        private Required GenerateTransactionMatrix(IList <sp_GetMappingViewModelData_Result> lstMappingViewModel, Required r, string txnID, MappingViewModel mappingViewModel)
        {
            try
            {
                List <string> lstAttributes = GetListofAttributesMapped(lstMappingViewModel, txnID, mappingViewModel, r);

                int tmCount = 1;
                foreach (var item in r.dicCriticalAttributes)
                {
                    tmCount *= item.Value;
                }

                CreateHeadersForTM(r, lstAttributes);

                GenerateMappingTable(lstMappingViewModel, r, lstAttributes, txnID);

                int rowCount = RuleofN(lstAttributes, tmCount, txnID, r, Callback);

                rowCount = GenerateNegativeCases(r, lstAttributes, rowCount, txnID);

                return(r);
            }
            catch (Exception)
            {
                throw;
            }
        }
 public void Sorting()
 {
     this.SelectedMapping = null;
 }
예제 #13
0
        public void ViewModelWithViewModelToModelMappings_Explicit_InitiatedFromViewModel()
        {
            var person = new Person();
            var viewModel = new MappingViewModel(person);

            Assert.AreEqual(string.Empty, person.FirstName);
            Assert.AreEqual(person.FirstName, viewModel.FirstNameAsExplicit);

            viewModel.FirstNameAsExplicit = "geert";

            // Only view model model must have changed
            Assert.AreEqual("geert", viewModel.FirstNameAsExplicit);
            Assert.AreNotEqual(person.FirstName, viewModel.FirstNameAsExplicit);
        }
예제 #14
0
        public void Setup()
        {
            this.variableRowViewModels = new List <VariableRowViewModel>
            {
                new VariableRowViewModel(
                    (new ReferenceDescription()
                {
                    NodeId = new ExpandedNodeId(Guid.NewGuid()),
                    DisplayName = new LocalizedText("", "el.DummyVariable0")
                }, new DataValue()
                {
                    Value = .2
                })),

                new VariableRowViewModel(
                    (new ReferenceDescription()
                {
                    NodeId = new ExpandedNodeId(Guid.NewGuid()),
                    DisplayName = new LocalizedText("", "res0.DummyVariable1")
                }, new DataValue())),

                new VariableRowViewModel(
                    (new ReferenceDescription()
                {
                    NodeId = new ExpandedNodeId(Guid.NewGuid()),
                    DisplayName = new LocalizedText("", "trans0.Gain.DummyVariable2")
                }, new DataValue()))
            };

            this.parameter0 = new Parameter(Guid.NewGuid(), null, null)
            {
                ParameterType = new TextParameterType(), ValueSet =
                {
                    new ParameterValueSet()
                    {
                        Computed  = new ValueArray <string>(new [] { "-" }),
                        Manual    = new ValueArray <string>(new [] { "-" }),
                        Reference = new ValueArray <string>(new []{ "-"                                                }),
                        Published = new ValueArray <string>(new []{ "-"                                                })
                    }
                }
            };

            this.element0 = new ElementDefinition(Guid.NewGuid(), null, null)
            {
                Parameter =
                {
                    this.parameter0,
                    new Parameter(Guid.NewGuid(),null,  null),
                }
            };

            this.elementUsage = new ElementUsage(Guid.NewGuid(), null, null)
            {
                ElementDefinition = this.element0,
                ParameterOverride =
                {
                    new ParameterOverride(Guid.NewGuid(), null, null)
                    {
                        Parameter = this.parameter0,
                        ValueSet  =
                        {
                            new ParameterOverrideValueSet()
                            {
                                Computed  = new ValueArray <string>(new [] { "-" }),
                                Manual    = new ValueArray <string>(new [] { "-" }),
                                Reference = new ValueArray <string>(new []{ "-"                                                }),
                                Published = new ValueArray <string>(new []{ "-"                                                })
                            }
                        }
                    }
                }
            };

            this.element0.ContainedElement.Add(this.elementUsage);

            this.iteration = new Iteration(Guid.NewGuid(), null, null)
            {
                TopElement = this.element0,
            };

            this.iteration.Element.Add(this.element0);

            this.hubController = new Mock <IHubController>();
            this.hubController.Setup(x => x.OpenIteration).Returns(this.iteration);

            this.dstMapResult = new ReactiveList <ElementBase>();
            this.hubMapResult = new ReactiveList <MappedElementDefinitionRowViewModel>();

            this.dstController = new Mock <IDstController>();
            this.dstController.Setup(x => x.MappingDirection).Returns(MappingDirection.FromHubToDst);
            this.dstController.Setup(x => x.DstMapResult).Returns(this.dstMapResult);

            this.dstController.Setup(x => x.HubMapResult).Returns(this.hubMapResult);

            this.dstController.Setup(x => x.ParameterVariable).Returns(new Dictionary <ParameterOrOverrideBase, VariableRowViewModel>()
            {
                { this.parameter0, this.variableRowViewModels.FirstOrDefault() }
            });

            this.dstVariableViewModel = new Mock <IDstVariablesControlViewModel>();

            this.dstVariableViewModel.Setup(x => x.Variables)
            .Returns(new ReactiveList <VariableRowViewModel>(this.variableRowViewModels));

            this.viewModel = new MappingViewModel(this.dstController.Object, this.hubController.Object, this.dstVariableViewModel.Object);
        }
        private void LoadMappingFromService(int pid, int mappingId, string entityName)
        {
            EntityWithETag<MdmId> mappingFromService = this.mappingService.GetMapping(entityName, pid, mappingId);

            this.Mapping = new MappingViewModel(mappingFromService, this.eventAggregator);
            this.RaisePropertyChanged(string.Empty);
        }
예제 #16
0
 public ActionResult UpdateTour(int id, string startOfTour, string endOfTour,
                                int?typeOfTourId, int?typeOfHotelsId, int?maxNumberOfPeople, int?price,
                                int?cityId, string isHot, int?numberOfOrders)
 {
     if (Request.HttpMethod == "POST")
     {
         var      tour            = MappingViewModel.MapTourViewModel(_managerService.GetTourById(id));
         DateTime startOfTourDate = DateTime.MinValue;
         DateTime endOfTourDate   = DateTime.MinValue;
         bool     update          = false;
         if (!string.IsNullOrEmpty(startOfTour) || !string.IsNullOrEmpty(endOfTour))
         {
             startOfTourDate = Convert.ToDateTime(startOfTour);
             endOfTourDate   = Convert.ToDateTime(endOfTour);
             if (startOfTourDate > endOfTourDate)
             {
                 ModelState.AddModelError("date", "Enter valid dates");
             }
             else
             {
                 tour.StartOfTour = startOfTourDate;
                 tour.StartOfTour = endOfTourDate;
                 update           = true;
             }
         }
         if (ModelState.IsValid)
         {
             if (typeOfTourId != null)
             {
                 tour.TypeOfTourId = typeOfTourId.Value;
                 update            = true;
             }
             if (typeOfHotelsId != null)
             {
                 tour.TypeOfHotelId = typeOfHotelsId.Value;
                 update             = true;
             }
             if (maxNumberOfPeople != null)
             {
                 tour.MaxNumberOfPeople = maxNumberOfPeople.Value;
                 update = true;
             }
             if (price != null)
             {
                 tour.Price = price.Value;
                 update     = true;
             }
             if (cityId != null)
             {
                 tour.CityId = cityId.Value;
                 update      = true;
             }
             if (numberOfOrders != null)
             {
                 tour.NumberOfOrders = numberOfOrders.Value;
                 update = true;
             }
             bool isHotType = Convert.ToBoolean(isHot);
             if (!((tour.IsHot && isHotType) ||
                   (!tour.IsHot && !isHotType)))
             {
                 tour.IsHot = Convert.ToBoolean(isHot);
                 update     = true;
             }
             if (update)
             {
                 var updateTour = MappingViewModel.MapTourDTO(tour);
                 _managerService.UpdateTour(updateTour);
                 SLogger.InfoToFile($"Manager updated tour id: {updateTour.Id}");
                 var messageInfo = new MessageViewModel()
                 {
                     Status = "success",
                     Info   = "Tour updated"
                 };
                 return(RedirectToAction("Index", messageInfo));
             }
             else
             {
                 ViewBag.ListOption = _managerService.GetListOption();
                 ModelState.AddModelError("Update", "Tour not updated");
                 return(View(tour));
             }
         }
         else
         {
             ViewBag.ListOption = _managerService.GetListOption();
             return(View(tour));
         }
     }
     else
     {
         ViewBag.ListOption = _managerService.GetListOption();
         var tour = MappingViewModel.MapTourViewModel(_managerService.GetTourById(id));
         if (tour == null)
         {
             return(HttpNotFound());
         }
         if (tour.NumberOfOrders <= 0)
         {
             return(HttpNotFound());
         }
         return(View(tour));
     }
 }
예제 #17
0
        public static List <RecordValueViewModel> Crawl(MappingViewModel map)
        {
            List <RecordValueViewModel> records = new List <RecordValueViewModel>();
            HtmlDocument doc        = new HtmlDocument();
            int          counter    = 0;
            var          jsonResult = RequestHelper.RequestWithJsonContentType(map.Url);

            if (jsonResult != null)
            {
                //it's json type
                doc.LoadHtml(jsonResult.ToString());
                var container = doc.DocumentNode.SelectSingleNode(GetApproporiateStringForJson(map.Selector));
                if (map.Entity != null)
                {
                    while (true)
                    {
                        string xpath    = GetApproporiateStringForJson(map.Entity.Selector);
                        var    entities = container.SelectNodes(xpath);
                        if (entities == null || counter == entities.Count)
                        {
                            break;
                        }
                        var currentEntity = entities[counter++];
                        if (currentEntity == null)
                        {
                            break;
                        }
                        string reference = Guid.NewGuid().ToString();
                        foreach (var item in map.Entity.Properties)
                        {
                            string value = currentEntity.SelectSingleNode(GetApproporiateStringForJson(item.Selector)).InnerText;
                            records.Add(new RecordValueViewModel()
                            {
                                Value        = value,
                                Reference    = reference,
                                PropertyCode = item.Id
                            });
                        }
                    }
                    return(records);
                }
                return(null);
            }
            else
            {
                //it's html type, so jsonResult is null
                HtmlWeb web = new HtmlWeb();
                doc = web.Load(map.Url);
                var container = doc.DocumentNode.SelectSingleNode(map.Selector);
                if (map.Entity != null)
                {
                    while (true)
                    {
                        string xpath    = map.Entity.Selector;
                        var    entities = container.SelectNodes(xpath);
                        if (entities == null || counter == entities.Count)
                        {
                            break;
                        }
                        var currentEntity = entities[counter++];
                        if (currentEntity == null)
                        {
                            break;
                        }
                        string reference = Guid.NewGuid().ToString();
                        foreach (var item in map.Entity.Properties)
                        {
                            string value = currentEntity.SelectSingleNode(item.Selector).InnerText.Trim();
                            records.Add(new RecordValueViewModel()
                            {
                                Value        = value,
                                Reference    = reference,
                                PropertyCode = item.Id
                            });
                        }
                    }
                    return(records);
                }
                return(null);
            }
        }
예제 #18
0
 public ActionResult CreateNewTour(string startOfTour, string endOfTour,
                                   int?typeOfTourId, int?typeOfHotelsId, int?maxNumberOfPeople, int?price,
                                   int?cityId, int?numberOfOrders, HttpPostedFileBase upload)
 {
     if (Request.HttpMethod == "POST")
     {
         DateTime startOfTourDate = DateTime.MinValue;
         DateTime endOfTourDate   = DateTime.MinValue;
         if (string.IsNullOrEmpty(startOfTour) || string.IsNullOrEmpty(endOfTour))
         {
             ModelState.AddModelError("date", "Enter valid dates");
         }
         else
         {
             startOfTourDate = Convert.ToDateTime(startOfTour);
             endOfTourDate   = Convert.ToDateTime(endOfTour);
             if (startOfTourDate > endOfTourDate)
             {
                 ModelState.AddModelError("date", "Enter valid dates");
             }
         }
         if (upload == null)
         {
             ModelState.AddModelError("upload", "Please enter image");
         }
         if (typeOfTourId == null)
         {
             ModelState.AddModelError("typeOfTourId", "Please enter type of tour");
         }
         if (typeOfHotelsId == null)
         {
             ModelState.AddModelError("typeOfHotelsId", "Please enter type of hotel");
         }
         if (maxNumberOfPeople == null)
         {
             ModelState.AddModelError("maxNumberOfPeople", "Please enter max number of people");
         }
         if (price == null)
         {
             ModelState.AddModelError("price", "Please enter price");
         }
         if (cityId == null)
         {
             ModelState.AddModelError("cityId", "Please enter a city");
         }
         if (numberOfOrders == null)
         {
             ModelState.AddModelError("typeOfTourId", "Please enter number of orders");
         }
         if (ModelState.IsValid)
         {
             var newTour = new TourViewModel()
             {
                 StartOfTour       = startOfTourDate,
                 EndOfTour         = endOfTourDate,
                 TypeOfHotelId     = typeOfHotelsId.Value,
                 TypeOfTourId      = typeOfTourId.Value,
                 MaxNumberOfPeople = maxNumberOfPeople.Value,
                 IsDelete          = false,
                 NumberOfOrders    = numberOfOrders.Value,
                 Price             = price.Value,
                 CityId            = cityId.Value,
                 IsHot             = false,
                 ImagePath         = Path.GetFileName(upload.FileName)
             };
             upload.SaveAs(Server.MapPath("~/Content/Image/" + newTour.ImagePath));
             var newTourDTO = MappingViewModel.MapTourDTO(newTour);
             _adminService.CreateTour(newTourDTO);
             SLogger.InfoToFile($"Admin create a new tour");
             var messageInfo = new MessageViewModel()
             {
                 Status = "success",
                 Info   = "Tour created"
             };
             return(RedirectToAction("Index", messageInfo));
         }
         else
         {
             var listOption = _adminService.GetListOption();
             return(View(listOption));
         }
     }
     else
     {
         var listOption = _adminService.GetListOption();
         return(View(listOption));
     }
 }
        private void Save(SaveEvent saveEvent)
        {
            if (this.ShouldDeleteAndRecreate())
            {
                var errorMessage = this.DeleteAndRecreate();

                if (errorMessage == null)
                {
                    this.Mapping = new MappingViewModel(this.eventAggregator);
                    this.navigationService.NavigateMainBackWithStatus(new StatusEvent(Message.MappingUpdated));
                    return;
                }

                this.eventAggregator.Publish(new ErrorEvent(string.Format(Message.MappingUpdateFailed, errorMessage)));
                return;
            }

            var response = this.mappingService.UpdateMapping(
                this.entityName,
                this.Mapping.MappingId.Value,
                this.entityId,
                new EntityWithETag<MdmId>(this.Mapping.Model(), this.Mapping.ETag));

            if (response.IsValid)
            {
                this.Mapping = new MappingViewModel(this.eventAggregator);
                this.navigationService.NavigateMainBackWithStatus(new StatusEvent(Message.MappingUpdated));
                return;
            }

            this.eventAggregator.Publish(
                new ErrorEvent(response.Fault != null ? response.Fault.Message : "Unkown Error"));
        }
예제 #20
0
        public void ViewModelWithViewModelToModelMappings_Explicit_InitiatedFromViewModel()
        {
            var person = new Person();
            var viewModel = new MappingViewModel(person);

            Assert.AreEqual(string.Empty, person.FirstName);
            Assert.AreEqual(person.FirstName, viewModel.FirstNameAsExplicit);

            viewModel.FirstNameAsExplicit = "geert";

            // When initiated from VM => nothing should change
            Assert.AreEqual("geert", viewModel.FirstNameAsExplicit);
            Assert.AreNotEqual(person.FirstName, viewModel.FirstNameAsExplicit);
        }
예제 #21
0
        public void ViewModelWithViewModelToModelMappings_OneWayToSource_InitiatedFromViewModel()
        {
            var person = new Person();
            var viewModel = new MappingViewModel(person);

            Assert.AreEqual(string.Empty, person.FirstName);
            Assert.AreEqual(person.FirstName, viewModel.FirstNameAsOneWayToSource);

            viewModel.FirstNameAsOneWayToSource = "geert";

            // Both must have changed
            Assert.AreEqual("geert", viewModel.FirstNameAsOneWayToSource);
            Assert.AreEqual(person.FirstName, viewModel.FirstNameAsOneWayToSource);
        }
예제 #22
0
 public MappingView(IntPtr handle) : base(handle)
 {
     ViewModel = new MappingViewModel();
 }
예제 #23
0
        public void ViewModelWithViewModelToModelMappings_Explicit_InitiatedManually()
        {
            var person = new Person();
            var viewModel = new MappingViewModel(person);

            Assert.AreEqual(string.Empty, person.FirstName);
            Assert.AreEqual(person.FirstName, viewModel.FirstNameAsExplicit);

            viewModel.FirstNameAsExplicit = "geert";
            viewModel.UpdateExplicitMappings();

            // Both must have changed
            Assert.AreEqual("geert", viewModel.FirstNameAsExplicit);
            Assert.AreEqual(person.FirstName, viewModel.FirstNameAsExplicit);
        }
예제 #24
0
        public ActionResult TourСatalog(int?sort, int?sortType, int page = 1)
        {
            var activeTours          = _customerService.GetActiveTours();
            var activeToursViewModel = MappingViewModel.MapTourListViewModel(activeTours);

            int pageSize            = 6;
            var activeToursPerPages = activeToursViewModel.Skip((page - 1) * pageSize).Take(pageSize);
            var pageInfo            = new PageInfo {
                PageNumber = page, PageSize = pageSize, TotalItems = activeToursViewModel.Count
            };
            var ivm = new TourPaginViewModel {
                PageInfo = pageInfo, Tours = activeToursPerPages.ToList()
            };

            if (Request.HttpMethod == "POST")
            {
                if (sort != null && sortType != null)
                {
                    switch (sort.Value)
                    {
                    case 1:
                    {
                        if (sortType.Value == 1)
                        {
                            ivm.Tours.Sort((x, y) => x.Price.CompareTo(y.Price));
                        }
                        else
                        {
                            ivm.Tours.Sort((x, y) => y.Price.CompareTo(x.Price));
                        }
                        break;
                    }

                    case 2:
                    {
                        if (sortType.Value == 1)
                        {
                            ivm.Tours.Sort((x, y) => x.TypeOfTourId.CompareTo(y.TypeOfTourId));
                        }
                        else
                        {
                            ivm.Tours.Sort((x, y) => y.TypeOfTourId.CompareTo(x.TypeOfTourId));
                        }
                        break;
                    }

                    case 3:
                    {
                        if (sortType.Value == 1)
                        {
                            ivm.Tours.Sort((x, y) => x.MaxNumberOfPeople.CompareTo(y.MaxNumberOfPeople));
                        }
                        else
                        {
                            ivm.Tours.Sort((x, y) => y.MaxNumberOfPeople.CompareTo(x.MaxNumberOfPeople));
                        }
                        break;
                    }

                    case 4:
                    {
                        if (sortType.Value == 1)
                        {
                            ivm.Tours.Sort((x, y) => x.TypeOfHotel.NumberOfStars.CompareTo(y.TypeOfHotel.NumberOfStars));
                        }
                        else
                        {
                            ivm.Tours.Sort((x, y) => y.TypeOfHotel.NumberOfStars.CompareTo(x.TypeOfHotel.NumberOfStars));
                        }
                        break;
                    }

                    case 5:
                    {
                        if (sortType.Value == 1)
                        {
                            ivm.Tours.Sort((x, y) => x.StartOfTour.CompareTo(y.StartOfTour));
                        }
                        else
                        {
                            ivm.Tours.Sort((x, y) => y.StartOfTour.CompareTo(x.StartOfTour));
                        }
                        break;
                    }

                    default:
                        break;
                    }
                }
                return(View(ivm));
            }
            else
            {
                return(View(ivm));
            }
        }
예제 #25
0
        private static List <RecordValueViewModel> GetReordsFromJson(JObject jsonResult, MappingViewModel map)
        {
            List <RecordValueViewModel> records = new List <RecordValueViewModel>();
            HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();

            doc.LoadHtml(jsonResult.ToString());
            var container = doc.DocumentNode.SelectSingleNode(GetApproporiateStringForJson(map.FirstSelector));

            if (container == null)
            {
                return(null);
            }

            string xpath    = GetApproporiateStringForJson(map.SecondSelector);
            var    entities = container.SelectNodes(xpath);

            if (entities == null)
            {
                return(null);
            }
            int counter = 0;

            while (true)
            {
                if (counter == entities.Count)
                {
                    break;
                }
                var currentEntity = entities[counter++];
                if (currentEntity == null)
                {
                    break;
                }
                string reference = Guid.NewGuid().ToString();
                foreach (var item in map.Properties)
                {
                    string value = currentEntity.SelectSingleNode(GetApproporiateStringForJson(item.Selector)).InnerText;
                    records.Add(new RecordValueViewModel()
                    {
                        Value        = value,
                        Reference    = reference,
                        PropertyCode = item.Id,
                        Property     = item
                    });
                }
            }
            return(records);
        }
예제 #26
0
 public EditMappingWindow(MappingViewModel vm)
 {
     InitializeComponent();
     DataContext = vm;
 }