public async Task Delete(int branchInformationId)
        {
            BranchInformation branchInformation = this.GetById(branchInformationId);

            _context.Remove(branchInformation);
            await _context.SaveChangesAsync();
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,BranchName,BranchCode,City,Province")] BranchInformation branchInformation)
        {
            if (id != branchInformation.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _branchInformationService.UpdateBranchInformation(branchInformation.Id, branchInformation.BranchName, branchInformation.BranchCode, branchInformation.City, branchInformation.Province);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BranchInformationExists(branchInformation.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(branchInformation));
        }
        public async Task UpdateBranchInformationProvince(int branchInformationId, string newProvince)
        {
            BranchInformation branchInformation = this.GetById(branchInformationId);

            branchInformation.Province = newProvince;

            await _context.SaveChangesAsync();
        }
        public async Task UpdateBranchInformationCity(int branchInformationId, string newCity)
        {
            BranchInformation branchInformation = this.GetById(branchInformationId);

            branchInformation.City = newCity;

            await _context.SaveChangesAsync();
        }
        public async Task UpdateBranchInformationBranchCode(int branchInformationId, string newBranchCode)
        {
            BranchInformation branchInformation = this.GetById(branchInformationId);

            branchInformation.BranchCode = newBranchCode;

            await _context.SaveChangesAsync();
        }
        public IActionResult Create([Bind("Id,BranchName,BranchCode,City,Province")] BranchInformation branchInformation)
        {
            if (branchInformation == null)
            {
                return(BadRequest("Branch Information is null"));
            }

            _branchInformationService.Create(branchInformation);
            return(RedirectToAction(nameof(Index)));
        }
        public async Task UpdateBranchInformation(int branchlInformationId, string newBranchName, string newBranchCode, string newCity, string newProvince)
        {
            BranchInformation branchInformation = this.GetById(branchlInformationId);

            branchInformation.BranchName = newBranchName;
            branchInformation.BranchCode = newBranchCode;
            branchInformation.City       = newCity;
            branchInformation.Province   = newProvince;

            await _context.SaveChangesAsync();
        }
        public DropRepoViewModel(IScreen hostScreen, IAppState appState, IRepoAnalysisProvider analyzeFunc)
        {
            HostScreen = hostScreen;

            AnalyzeRepo = new ReactiveAsyncCommand();

            CoreUtility.ExtractLibGit2();

            var scanResult = AnalyzeRepo.RegisterAsyncObservable(x => analyzeFunc.AnalyzeRepo((string)x));

            scanResult.Select(x => x.Item1).ToProperty(this, x => x.CurrentRepoPath);
            scanResult
            .Select(x => x.Item2.Select(y => (IBranchInformationViewModel) new BranchInformationViewModel(y.Key, y.Value)))
            .Select(x => new ReactiveCollection <IBranchInformationViewModel>(x))
            .ToProperty(this, x => x.BranchInformation);

            this.WhenAny(x => x.BranchInformation, x => x.Value != null ? Visibility.Visible : Visibility.Hidden)
            .ToProperty(this, x => x.RepairButtonVisibility);

            RepairButton = new ReactiveCommand();
            RepairButton.Subscribe(_ => {
                appState.BranchInformation           = BranchInformation.Where(x => x.BranchName != Constants.WorkingDirectory).ToArray();
                appState.WorkingDirectoryInformation = BranchInformation.First(x => x.BranchName == Constants.WorkingDirectory).Model;
                appState.CurrentRepo = CurrentRepoPath;

                HostScreen.Router.Navigate.Execute(RxApp.GetService <IRepairViewModel>());
            });

            var viewStates = Observable.Merge(
                AnalyzeRepo.ItemsInflight.Where(x => x > 0).Select(_ => "Analyzing"),
                scanResult.Select(_ => "RepoAdded"));

            MessageBus.Current.RegisterMessageSource(viewStates, "DropRepoViewState");

            this.WhenNavigatedTo(() =>
                                 MessageBus.Current.Listen <string>("DropFolder").Subscribe(path => AnalyzeRepo.Execute(path)));
        }
        public async Task UpdatePersonalInformation(int personalInformationId, string newFirstName, string newLastName, string newEmailAddress, string newContactNumber, string newAlternativeContactNumber, string newAddress, string newMethodOfContact, string newProfileImageUrl, DateTime newJoiningDate, BranchInformation newBranchInformation, ApplicationUser newAppUser)
        {
            PersonalInformation personalInformation = this.GetById(personalInformationId);

            personalInformation.FirstName                = newFirstName;
            personalInformation.LastName                 = newLastName;
            personalInformation.EmailAddress             = newEmailAddress;
            personalInformation.ContactNumber            = newContactNumber;
            personalInformation.AlternativeContactNumber = newAlternativeContactNumber;
            personalInformation.Address         = newAddress;
            personalInformation.MethodOfContact = newMethodOfContact;
            personalInformation.ProfileImageUrl = newProfileImageUrl;
            personalInformation.JoiningDate     = newJoiningDate;
            personalInformation.Branch          = newBranchInformation;
            personalInformation.AppUser         = newAppUser;

            await _context.SaveChangesAsync();
        }
        public async Task UpdatePersonalInformationBranchInformation(int personalInformationId, BranchInformation newBranchInformation)
        {
            PersonalInformation personalInformation = this.GetById(personalInformationId);

            personalInformation.Branch = newBranchInformation;

            await _context.SaveChangesAsync();
        }
        private XmlElement createDocumentSubsidyInformation(SubsidyControl subsidyControl, SubsidySsoAccountBranchControl accountBranchControl, string[] lines)
        {
            SubsidyInformation subsidyInformation = new SubsidyInformation();

            subsidyInformation.SubsidyRate  = subsidyControl.subsidyRate;
            subsidyInformation.SubsidyMonth = "--" + subsidyControl.subsidyMonth + "--";
            subsidyInformation.SubsidyYear  = subsidyControl.subsidyYear;
            //subsidyInformation.TotalWageAmount = subsidyControl.totalWageAmount;
            subsidyInformation.TotalWageAmount = new TotalWageAmount {
                totalWageAmount = subsidyControl.totalWageAmount, currencyID = "THB"
            };
            subsidyInformation.TotalEmployeeSubsidyAmount = new TotalEmployeeSubsidyAmount {
                totalEmployeeSubsidyAmount = subsidyControl.totalEmployeeSubsidyAmount, currencyID = "THB"
            };
            subsidyInformation.TotalEmployerSubsidyAmount = new TotalEmployerSubsidyAmount {
                totalEmployerSubsidyAmount = subsidyControl.totalEmployerSubsidyAmount, currencyID = "THB"
            };
            subsidyInformation.TotalSubsidyAmount = new TotalSubsidyAmount {
                totalSubsidyAmount = subsidyControl.totalSubsidyAmount, currencyID = "THB"
            };
            subsidyInformation.TotalEmployeeNumber = subsidyControl.totalNumberOfEmployee;

            //########################  Set Data SsoClass.
            ssoClass.SUBSIDY_RATE          = subsidyControl.subsidyRate;
            ssoClass.SUBSIDY_MONTH         = subsidyControl.subsidyMonth;
            ssoClass.SUBSIDY_YEAR          = subsidyControl.subsidyYear;
            ssoClass.TOTAL_WAGE_AMOUNT     = subsidyControl.totalWageAmount;
            ssoClass.TOTAL_EMPLOYEE_AMOUNT = subsidyControl.totalEmployeeSubsidyAmount;
            ssoClass.TOTAL_EMPLOYER_AMOUNT = subsidyControl.totalEmployerSubsidyAmount;
            ssoClass.TOTAL_EMPLOYER_NO     = subsidyControl.totalNumberOfEmployee;
            //########################  BranchInformation.
            BranchInformation branchInformation = new BranchInformation();

            branchInformation.branchItem                       = new BranchItem();
            branchInformation.branchItem.ItemNumber            = "1";
            branchInformation.branchItem.SSOBranchCode         = accountBranchControl.ssoAccountBranch;
            branchInformation.branchItem.TotalBranchWageAmount = new TotalBranchWageAmount {
                totalBranchWageAmount = accountBranchControl.totalBranchWageAmount, currencyID = "THB"
            };
            branchInformation.branchItem.TotalBranchEmployeeSubsidyAmount = new TotalBranchEmployeeSubsidyAmount {
                totalBranchEmployeeSubsidyAmount = accountBranchControl.totalBranchEmployeeSubsidyAmount, currencyID = "THB"
            };
            branchInformation.branchItem.TotalBranchEmployerSubsidyAmount = new TotalBranchEmployerSubsidyAmount {
                totalBranchEmployerSubsidyAmount = accountBranchControl.totalBranchEmployerSubsidyAmount, currencyID = "THB"
            };
            branchInformation.branchItem.TotalBranchSubsidyAmount = new TotalBranchSubsidyAmount {
                totalBranchSubsidyAmount = accountBranchControl.totalBranchSubsidyAmount, currencyID = "THB"
            };
            branchInformation.branchItem.TotalBranchEmployeeNumber = accountBranchControl.totalBranchNumberOfEmployee;
            //branchInformation.branchItem.TotalBranchEmployeeNumber = "1";
            //########################  ItemInformation
            ItemInformation itemInformation = new ItemInformation();

            int countLine = 1;
            List <SubsidyItem> subsidySsoDetails = new List <SubsidyItem>();

            foreach (string line in lines)
            {
                SubsidySsoDetail subsidySsoDetail = new SubsidySsoDetail();
                subsidySsoDetail.setSubsidySsoDetail(line);

                SubsidyItem subsidyItem = new SubsidyItem();
                subsidyItem.ItemNumber = countLine.ToString();
                subsidyItem.WageAmount = new WageAmount {
                    wageAmount = subsidySsoDetail.wageAmount, currencyID = "THB"
                };
                subsidyItem.SubsidyAmount = new SubsidyAmount {
                    subsidyAmount = subsidySsoDetail.employeeSubsidyAmount, currencyID = "THB"
                };
                //subsidyItem.WageAmount = new WageAmount { wageAmount = "20000", currencyID = "THB" };
                // subsidyItem.SubsidyAmount = new SubsidyAmount { subsidyAmount = "750", currencyID = "THB" };
                subsidyItem.LastEntry = subsidySsoDetail.lastEntry;

                subsidyItem.employeeInformation                  = new EmployeeInformation();
                subsidyItem.employeeInformation.EmployeeID       = subsidySsoDetail.employeeIdCard;
                subsidyItem.employeeInformation.EmployeeTitle    = subsidySsoDetail.employeeTitle;
                subsidyItem.employeeInformation.EmployeeName     = subsidySsoDetail.employeeName;
                subsidyItem.employeeInformation.EmployeeLastName = subsidySsoDetail.employeeLastName;

                subsidySsoDetails.Add(subsidyItem);
                countLine++;
            }
            itemInformation.subsidyItem = subsidySsoDetails;

            subsidyInformation.branchInformation = branchInformation;
            subsidyInformation.branchInformation.branchItem.itemInformation = itemInformation;
            //subsidyInformation.branchInformation = new BranchInformation();



            XmlSerializerNamespaces xmlSerializerNamespaces = new XmlSerializerNamespaces();

            xmlSerializerNamespaces.Add("", "");

            XmlDocument   xmlDocument   = new XmlDocument();
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(SubsidyInformation));

            using (XmlWriter writer = xmlDocument.CreateNavigator().AppendChild()) {
                xmlSerializer.Serialize(writer, subsidyInformation, xmlSerializerNamespaces);
            }
            return(xmlDocument.DocumentElement);
        }
 public async Task Create(BranchInformation branchInformation)
 {
     _context.Add(branchInformation);
     await _context.SaveChangesAsync();
 }