예제 #1
0
        public void a_blank_model_is_invalid()
        {
            var vm = new DeclarationViewModel();

            vm.Validate();

            Assert.AreEqual(false, vm.IsValid);
        }
예제 #2
0
        public DetailedDeclarationPage(Declaration declaration)
        {
            ToolbarItems.Add(new ToolbarItem("Submit", null, onSubmit));

            vm = new DeclarationViewModel(declaration);
            this.BindingContext = vm;
            vm.Navigation       = Navigation;
            InitializeComponent();
        }
        public EneditableDeclarationPage(Declaration declaration)
        {
            ToolbarItems.Add(new ToolbarItem("Delete", null, onDelete));

            vm = new DeclarationViewModel(declaration.ID);
            this.BindingContext = vm;

            vm.Navigation = Navigation;
            InitializeComponent();
        }
        public ActionResult Create(DeclarationViewModel declarationViewModel)
        {
            if (ModelState.IsValid)
            {
                _declarationManager.IsRegister(declarationViewModel);
                return(RedirectToAction("Create", "NomineeDetails"));
            }

            return(View(declarationViewModel));
        }
예제 #5
0
 public void Setup()
 {
     validModel = new DeclarationViewModel
     {
         SignatoryName = "The name of the signatory",
         SignatureDate = new DateViewModel
         {
             Date = new DateTime(2000, 01, 01)
         }
     };
 }
        public ActionResult Index(DeclarationViewModel model)
        {
            session.SetString("LastSubmittedPageSection", "Index");
            session.SetString("LastSubmittedPageId", "Declaration");

            if (!ModelState.IsValid)
            {
                return(View("Index", model));
            }

            licenceApplicationPostDataHandler.Update(session.GetCurrentLicenceId(), x => x, model);

            return(RedirectToAction("TaskList", "Licence"));
        }
        private DeclarationViewModel MapLevyDeclarationViewModel(Declaration declaration)
        {
            var levy = new DeclarationViewModel
            {
                SubmissionDate             = GetSubmissionDate(declaration.SubmissionTime),
                PayrollDate                = GetPayrollDate(declaration.PayrollPeriod),
                LevySubmissionId           = declaration.Id,
                LevyDeclarationDescription = GetLevyDeclarationDescription(declaration),
                YearToDateAmount           = GetYearToDateAmount(declaration),
                SubmissionStatus           = declaration.LevyDeclarationSubmissionStatus
            };

            return(levy);
        }
        public void it_should_map_the_declaration_view_model_to_the_licence_entity()
        {
            var input = new DeclarationViewModel
            {
                SignatoryName = "Demo Signatory",
                SignatureDate = new DateViewModel
                {
                    Date = new DateTime(2017, 1, 1)
                }
            };

            var result = this.mapper.Map <Licence>(input);

            Assert.AreEqual(input.SignatoryName, result.SignatoryName);
            Assert.AreEqual(input.SignatureDate.Date, result.SignatureDate);
        }
        public IActionResult Create(DeclarationViewModel declarationViewModel)
        {
            var userId = HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);

            //var warehouseId = context.Users.FirstOrDefault(x => x.Id == userId).WarehouseId;

            if (ModelState.IsValid)
            {
                Declarations declarations = new Declarations()
                {
                    UserId          = userId,
                    CountryId       = 2,
                    TrackingCode    = "qwerty",
                    Warehouse_Id    = declarationViewModel.Warehouse_Id,
                    Shop            = declarationViewModel.Shop,
                    OrderNumber     = declarationViewModel.OrderNumber,
                    ProductPrice    = declarationViewModel.ProductPrice,
                    DeliveryCode    = declarationViewModel.DeliveryCode,
                    ProductType     = declarationViewModel.ProductType,
                    Comment         = declarationViewModel.Comment,
                    FileName        = declarationViewModel.FileName,
                    Quantity        = declarationViewModel.Quantity,
                    DeclarationDate = DateTime.Now,
                };
                var result = declarationRepository.Add(declarations);

                if (result == true)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Emeliyyat ugursuzdur!");
                }
            }

            return(View(declarationViewModel));
        }
예제 #10
0
        private DeclarationViewModel FindOrAddNamespaceNode(NamespaceDecl ns)
        {
            List<NamespaceDecl> parents = new List<NamespaceDecl>();
            NamespaceDecl temp = ns.ParentNamespace;
            while (temp != null)
            {
                parents.Insert(0, temp);
                temp = temp.ParentNamespace;
            }

            DeclarationViewModel parentNode = null;

            if (parents.Count > 0)
            {
                foreach (NamespaceDecl parent in parents)
                {
                    if (parentNode == null)
                    {
                        parentNode = FindRootLevelItem(parent.Usr);
                    }
                    else
                    {
                        parentNode = parentNode.FindOrAddChildDecl(parent);
                        if (parentNode == null)
                            return null;
                    }
                }
                return parentNode.FindOrAddChildDecl(ns);
            }
            DeclarationViewModel result = FindRootLevelItem(ns.Usr);
            if(result == null)
            {
                result = new DeclarationViewModel(parentNode, ns);
                _root.Add(result);
            }
            return result;
        }
예제 #11
0
        private DeclarationViewModel FindOrAddClassNode(ClassDecl c)
        {
            if(c.Parent == null)
            {
                DeclarationViewModel vm = FindRootLevelItem(c.Usr);
                if (vm != null)
                    return vm;

                vm = new DeclarationViewModel(null, c);
                _root.Add(vm);
                return vm;
            }
            Debug.Assert(c.Parent != null);
            var parentnode = FindOrAddParentNode(c.Parent);
            return parentnode.FindOrAddChildDecl(c);
        }
예제 #12
0
        private DeclarationViewModel FindOrAddFunctionNode(FunctionDecl f)
        {
            if (f.Parent == null)
            {
                DeclarationViewModel vm = FindRootLevelItem(f.Usr);
                if (vm != null)
                    return vm;

                vm = new DeclarationViewModel(null, f);
                _root.Add(vm);
                return vm;
            }

            Debug.Assert(f.Parent != null);
            var parentnode = FindOrAddParentNode(f.Parent);
            return parentnode.FindOrAddChildDecl(f);
        }
 public void IsUpdate(DeclarationViewModel declarationViewModel)
 {
     _declarationRepository.IsUpdatee(declarationMapping.MapToModel(declarationViewModel));
     _declarationRepository.UnitOfWork.Save();
 }
 public void IsRegister(DeclarationViewModel declarationViewModel)
 {
     _declarationRepository.IsRegisterr(declarationMapping.MapToModel(declarationViewModel));
     _declarationRepository.UnitOfWork.Save();
 }
        /// <summary>
        ///  Returns data to bind on declaration form
        /// </summary>
        /// <returns></returns>
        public async Task <IResult> GetDeclarationFormData()
        {
            var formViewModel = new DeclarationViewModel
            {
                Locations = new List <OptionsViewModel>(),
                Questions = new List <OptionsViewModel>(),
                Symptoms  = new List <OptionsViewModel>(),
                Zones     = new List <OptionsViewModel>()
            };
            var result = new Result
            {
                Operation  = Operation.Read,
                Status     = Status.Success,
                StatusCode = HttpStatusCode.OK
            };

            try
            {
                var locations = await _locationRepository.GetLocations();

                if (locations.Any())
                {
                    formViewModel.Locations = locations.Select(t =>
                    {
                        var optionViewModel = new OptionsViewModel();
                        optionViewModel.MapFromModel(t);
                        return(optionViewModel);
                    }).ToList();
                }

                var zones = await _zoneRepository.GetZones();

                if (zones.Any())
                {
                    formViewModel.Zones = zones.Select(t =>
                    {
                        var optionViewModel = new OptionsViewModel();
                        optionViewModel.MapFromModel(t);
                        return(optionViewModel);
                    }).ToList();
                }

                var questions = await _questionRepository.GetQuestions();

                if (questions.Any())
                {
                    formViewModel.Questions = questions.Select(t =>
                    {
                        var optionViewModel = new OptionsViewModel();
                        optionViewModel.MapFromModel(t);
                        return(optionViewModel);
                    }).ToList();
                }


                var symptoms = await _symptomRepository.GetSymptoms();

                if (symptoms.Any())
                {
                    formViewModel.Symptoms = symptoms.Select(t =>
                    {
                        var optionViewModel = new OptionsViewModel();
                        optionViewModel.MapFromModel(t);
                        return(optionViewModel);
                    }).ToList();
                }
                result.Body = formViewModel;
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
                result.Status     = Status.Error;
                result.Message    = ex.Message;
                result.StatusCode = HttpStatusCode.InternalServerError;
            }
            return(result);
        }