Esempio n. 1
0
        public async Task <ActionResult> CreatePlan(PlanModel planModel)
        {
            DatabaseHelperClass databaseHelperClass = new DatabaseHelperClass("Password=123456789;Persist Security Info=True;User ID=sqlserver;Initial Catalog=epharma;Data Source=34.95.222.223");

            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception("Model is Invalid");
                }

                CreatePlanUserRepository createPlanUserRepository = new CreatePlanUserRepository(databaseHelperClass);
                DbCreatePlanUser         dbCreatePlanUser         = new DbCreatePlanUser(createPlanUserRepository);
                await dbCreatePlanUser.CreatePlanUser(planModel);

                return(Ok());
            }
            catch (Exception ex)
            {
                databaseHelperClass.connection.Close();
                return(StatusCode(500, "Internal Server Error"));
            }
        }
Esempio n. 2
0
        public async Task <ActionResult> CreatePlan([FromBody] PlanModel planModel)
        {
            DatabaseHelperClass databaseHelperClass = new DatabaseHelperClass("YOUR_CONNECTIONSTRING");

            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception("Model is Invalid");
                }

                CreatePlanUserRepository createPlanUserRepository = new CreatePlanUserRepository(databaseHelperClass);
                DbCreatePlanUser         dbCreatePlanUser         = new DbCreatePlanUser(createPlanUserRepository);
                await dbCreatePlanUser.CreatePlanUser(planModel);

                return(Ok());
            }
            catch (Exception ex)
            {
                databaseHelperClass.connection.Close();
                return(StatusCode(500, "Internal Server Error"));
            }
        }