private SOWEntryModel GetCreateStateModel()
        {
            SOWEntryFormData formData     = CreateFormData(null);
            List <Control>   formControls = CreateFormControls(0);
            var model = CreateModel(0);

            return(new SOWEntryModel()
            {
                FormData = formData,
                FormControls = formControls,
                Model = model
            });
        }
        private SOWEntryFormData CreateFormData(SOWDTO sowDTO)
        {
            if (sowDTO == null)
            {
                return(new SOWEntryFormData());
            }

            SOWEntryFormData formData = new SOWEntryFormData();

            var project = new ProjectQuery(this.Db).GetByPrimaryKey(sowDTO.Project_FK);

            if (project != null)
            {
                formData.Projects.Add(project);
            }

            var bts = new BTSQuery(this.Db).GetByPrimaryKey(sowDTO.BTS_FK);

            if (bts != null)
            {
                formData.BTSes.Add(bts);
            }

            foreach (var assign in sowDTO.SOWAssigns)
            {
                var user = new UserQuery(Db).GetByPrimaryKey(assign.User_FK);
                if (user != null)
                {
                    formData.Users.Add(user);
                }
            }

            foreach (var track in sowDTO.SOWTracks)
            {
                sowDTO.Technology_FK = track.TipePekerjaan_FK;
                var technology = new TechnologyQuery(this.Db).GetByPrimaryKey((int)track.TipePekerjaan_FK);
                if (technology != null)
                {
                    formData.Technologies.Add(technology);
                }
            }

            return(formData);
        }
        private SOWEntryModel GetUpdateStateModel(int sowPK)
        {
            List <Control> formControls = CreateFormControls(sowPK);
            SOWDTO         sowDTO       = CreateModel(sowPK);

            if (sowDTO == null)
            {
                throw new KairosException($"Record with primary key '{sowDTO.SOW_PK}' is not found.");
            }

            SOWEntryFormData formData = CreateFormData(sowDTO);

            return(new SOWEntryModel()
            {
                FormData = formData,
                FormControls = formControls,
                Model = sowDTO,
            });
        }