コード例 #1
0
        public ActionResult CreateProgram(ProgramCreate model)
        {
            var ctx = new ApplicationDbContext();

            if (ctx.Academies.FirstOrDefault(a => a.Name == model.AcademyName) == null)
            {
                ModelState.AddModelError("AcademyName", "Please create the academy first or enter an academy that already exists");
                return(View(model));
            }
            var service = GetBrowsingService();

            if (service.CreateProgram(model))
            {
                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
        }
コード例 #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int AddProgramNode(IDebugProgramNode2 pProgramNode)
        {
            //
            // Registers a program that can be debugged with the port it is running on.
            //

            LoggingUtils.PrintFunction();

            try
            {
                IDebugProcess2 process;

                DebuggeeProgram program = pProgramNode as DebuggeeProgram;

                LoggingUtils.RequireOk(program.GetProcess(out process));

                foreach (IDebugPortEvents2 connectionPoint in m_eventConnectionPoints.Values)
                {
                    ProgramCreate debugEvent = new ProgramCreate();

                    Guid eventGuid = ComUtils.GuidOf(debugEvent);

                    int handle = connectionPoint.Event(null, this, process, program, debugEvent, ref eventGuid);

                    if (handle == unchecked ((int)0x80010108)) // RPC_E_DISCONNECTED
                    {
                        continue;                              // Connection point was previously used.
                    }

                    LoggingUtils.RequireOk(handle);
                }

                return(Constants.S_OK);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                return(Constants.E_FAIL);
            }
        }
コード例 #3
0
        public bool CreateProgram(ProgramCreate model)
        {
            var     ctx       = new ApplicationDbContext();
            int     academyId = ctx.Academies.FirstOrDefault(a => a.Name == model.AcademyName).AcademyId;
            string  createdBy = ctx.Users.FirstOrDefault(u => u.Id == _userId).UserName;
            Program entity    = new Program
            {
                Name         = model.Name,
                Type         = model.Type,
                Prerequisite = model.Prerequisite,
                AcademyId    = academyId,
                AcademyName  = model.AcademyName,
                OwnerId      = _userId,
                CreatedBy    = createdBy
            };

            _context.Programs.Add(entity);
            var changeCount = _context.SaveChanges();

            return(changeCount == 1);
        }