Example #1
0
        private CostEntryModel GetUpdateStateModel(int costPK)
        {
            CostEntryFormData formData = new CostEntryFormData();

            List <Control> formControls = CreateFormControls(costPK);
            CostDTO        costDTO      = costQuery.GetByPrimaryKey(costPK);

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

            var costKategori = new CostKategoriQuery(Db).GetByPrimaryKey(costDTO.KategoriCost_FK);

            if (costKategori != null)
            {
                formData.CostKategoris.Add(costKategori);
            }


            return(new CostEntryModel()
            {
                FormData = formData,
                FormControls = formControls,
                Model = costDTO,
            });
        }
 public IHttpActionResult Get(int id)
 {
     ThrowIfUserHasNoRole(readRole);
     using (CostQuery costQuery = new CostQuery(Db))
     {
         var data = costQuery.GetByPrimaryKey(id);
         SaveLog("Cost", "Get", JsonConvert.SerializeObject(new { primaryKey = id }));
         return(Ok(new SuccessResponse(data)));
     }
 }