コード例 #1
0
        public bool AfiliarEstudianteacurso(UserEntity user, CourseEntity courseS)
        {
            SqlConnection con       = new SqlConnection("Server= arquisqlserver.database.windows.net; Database= arquitectura;User Id=arquisqlserver;Password = arquitectura2019!;");
            int           i         = 0;
            string        fullquery = "";
            //insert the information to the database
            StringBuilder stringquery = new StringBuilder();

            stringquery.Append("insert into CursoEstudiante (IdCurso,IdEstudiante) values");
            stringquery.Append("('" + courseS.IdCurso + "','" + user.IdPersona + "' )");
            fullquery = stringquery.ToString();
            SqlCommand cmd = new SqlCommand(fullquery, con);

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
                i = cmd.ExecuteNonQuery();
                con.Close();
            }
            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        public CourseEntity GetCourse(string nombreCurso, string areaCurso)
        {
            DataTable     dataTable = new DataTable();
            SqlConnection con = new SqlConnection("Server= arquisqlserver.database.windows.net; Database= arquitectura;User Id=arquisqlserver;Password = arquitectura2019!;"); int i = 0;
            //insert the information to the database
            StringBuilder stringquery = new StringBuilder();

            stringquery.Append("select * from Curso ");
            stringquery.Append("where NombreCurso= '" + nombreCurso + "'");
            stringquery.Append("and AreaCurso= '" + areaCurso + "'");

            CourseEntity course = new CourseEntity();



            SqlCommand cmd = new SqlCommand(stringquery.ToString(), con);

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        course.IdCurso          = dr.GetInt32(dr.GetOrdinal("IdCurso"));
                        course.DescripcionCurso = dr.GetString((dr.GetOrdinal("DescripcionCurso")));
                        course.AreaCurso        = dr.GetString((dr.GetOrdinal("AreaCurso")));
                        course.NombreCurso      = dr.GetString((dr.GetOrdinal("NombreCurso")));
                    }
                    con.Close();
                }
            }
            return(course);
        }
コード例 #3
0
        public bool insertCourseResponse(CourseEntity course)
        {
            SqlConnection con       = new SqlConnection("Server= arquisqlserver.database.windows.net; Database= arquitectura;User Id=arquisqlserver;Password = arquitectura2019!;");
            int           i         = 0;
            string        fullquery = "";
            //insert the information to the database
            StringBuilder stringquery = new StringBuilder();

            stringquery.Append("insert into Curso (NombreCurso,DescripcionCurso,AreaCurso) values");
            stringquery.Append("('" + course.NombreCurso + "','" + course.DescripcionCurso + "','" + course.AreaCurso + "' )");
            fullquery = stringquery.ToString();
            SqlCommand cmd = new SqlCommand(fullquery, con);

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
                i = cmd.ExecuteNonQuery();
                con.Close();
            }
            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
        public static List <CourseEntity> CourseList()
        {
            List <CourseEntity> values   = new List <CourseEntity>();
            SqlCommand          command2 = new SqlCommand("Select * from COURSE", Connection.con);

            if (command2.Connection.State != ConnectionState.Open)
            {
                command2.Connection.Open();
            }
            SqlDataReader dr = command2.ExecuteReader();

            while (dr.Read())
            {
                CourseEntity std = new CourseEntity
                {
                    ID         = Convert.ToInt32(dr["COURSEID"].ToString()),
                    COURSENAME = dr["COURSENAME"].ToString(),
                    MIN        = int.Parse(dr["COURSEMINCAPACITY"].ToString()),
                    MAX        = int.Parse(dr["COURSEMAXCAPACITY"].ToString())
                };
                values.Add(std);
            }
            dr.Close();
            return(values);
        }
コード例 #5
0
 protected CourseEntity GetExistingRecord(CourseEntity newCourse)
 {
     return(Repo.GetAll().FirstOrDefault(c => c.SemesterId.Equals(newCourse.SemesterId) &&
                                         c.Year.Equals(newCourse.Year) &&
                                         c.Department.Equals(newCourse.Department) &&
                                         c.Number.Equals(newCourse.Number)));
 }
コード例 #6
0
        public List <CourseEntity> listCourse()
        {
            List <CourseEntity> list = new List <CourseEntity>();

            try
            {
                sqlConnection.Open();
                sqlCommand             = new SqlCommand("list_course", sqlConnection);
                sqlCommand.CommandType = CommandType.StoredProcedure;

                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

                while (sqlDataReader.Read())
                {
                    CourseEntity course = new CourseEntity();
                    course.id_course        = Convert.ToInt32(sqlDataReader["Identificador"]);
                    course.course           = sqlDataReader["Curso"].ToString();
                    course.teacher.fullname = sqlDataReader["Catedratico"].ToString();

                    list.Add(course);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(list);
        }
コード例 #7
0
        public CourseEntity searchTeacher(int id)
        {
            CourseEntity course = new CourseEntity();

            try
            {
                sqlConnection.Open();
                sqlCommand             = new SqlCommand("search_course", sqlConnection);
                sqlCommand.CommandType = CommandType.StoredProcedure;

                SqlParameter id_parameter = new SqlParameter();
                id_parameter.ParameterName = "@idCourse";
                id_parameter.SqlDbType     = SqlDbType.Int;
                id_parameter.Value         = id;

                sqlCommand.Parameters.Add(id_parameter);

                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                sqlDataReader.Read();

                if (sqlDataReader.HasRows)
                {
                    course.id_course        = Convert.ToInt32(sqlDataReader["ID"]);
                    course.course           = sqlDataReader["Nombre"].ToString();
                    course.teacher.fullname = sqlDataReader["Profesor"].ToString();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(course);
        }
コード例 #8
0
ファイル: CourseController.cs プロジェクト: 13232989155/A6
        public JsonResult GetById([FromForm] int courseId)
        {
            DataResult dr = new DataResult();

            try
            {
                CourseBLL    courseBLL    = new CourseBLL();
                CourseEntity courseEntity = courseBLL.GetById(courseId);
                courseEntity.videoUrl = "";

                TeacherBLL teacherBLL = new TeacherBLL();
                courseEntity.teacherEntity = teacherBLL.GetById(courseEntity.teacherId);

                CourseOrderBLL courseOrderBLL = new CourseOrderBLL();
                courseEntity.countSold = courseOrderBLL.GetCountByCourseId(courseEntity.courseId);

                dr.code = "200";
                dr.data = courseEntity;
            }
            catch (Exception ex)
            {
                dr.code = "999";
                dr.msg  = ex.Message;
            }

            return(Json(dr));
        }
コード例 #9
0
        public BaseObject UpdateCourse(CourseEntity param)
        {
            var obj        = new BaseObject();
            var courseType = _db.Courses.FirstOrDefault(m => m.ID == param.ID);

            if (courseType == null)
            {
                obj.Tag     = -1;
                obj.Message = "该记录没找到";
                return(obj);
            }

            courseType.AddUserID    = param.AddUserID;
            courseType.Contact      = param.Contact;
            courseType.CourseName   = param.CourseName;
            courseType.CourseTypeID = param.CourseTypeID;
            courseType.StartDate    = param.StartDate;
            courseType.Description  = param.Description;
            courseType.IndustryID   = param.IndustryID;
            courseType.UserID       = param.UserID;
            courseType.AddDate      = DateTime.Now;
            courseType.AddUserID    = param.AddUserID;
            courseType.Amount       = param.Amount;
            courseType.CountPeople  = param.CountPeople;
            courseType.EndDate      = param.EndDate;
            courseType.Address      = param.Address;

            _db.SaveChanges();
            obj.Tag = 1;

            return(obj);
        }
コード例 #10
0
        public BaseObject InsertCourse(CourseEntity param)
        {
            var obj    = new BaseObject();
            var course = new Course();

            course.AddDate      = DateTime.Now;
            course.AddUserID    = param.AddUserID;
            course.Contact      = param.Contact;
            course.CourseName   = param.CourseName;
            course.CourseTypeID = param.CourseTypeID;
            course.StartDate    = param.StartDate;
            course.EndDate      = param.EndDate;
            course.Amount       = param.Amount;
            course.ApplyCount   = 0;
            course.CountPeople  = param.CountPeople;
            course.IsDelete     = PublicType.No;
            course.Visit        = 0;
            course.Description  = param.Description;
            course.IndustryID   = param.IndustryID;
            course.UserID       = param.UserID;
            course.State        = CourseState.NoAudit;
            course.Address      = param.Address;

            _db.Courses.Add(course);

            _db.SaveChanges();

            obj.Tag = 1;

            return(obj);
        }
コード例 #11
0
        public static List <CourseEntity> GetCourseList(int schoolId)
        {
            var list = new List <CourseEntity>();

            try
            {
                var apiUrl = Config.UpocCommonUrl + "Common/Index";
                var method = "GetCourseList";
                var dict   = new Dictionary <string, string>();
                dict.Add("appId", Config.AppId);
                dict.Add("method", method);
                dict.Add("schoolId", schoolId.ToString());
                var sign = Helper.GetSign(dict);
                dict.Add("sign", sign);
                var result = Helper.DoPost(apiUrl, dict);                 //提交post请求
                result = result.Replace("\r\n", "").Replace("\\", "");
                var resultData = Helper.FromJsonTo <Result <List <CourseEntity> > >(result);
                if (resultData.State == 1 && resultData.Data != null)
                {
                    list = resultData.Data;
                    var defaultEntity = new CourseEntity();
                    defaultEntity.CourseName = "全部科目";
                    list.Insert(0, defaultEntity);
                    return(list);
                }
                return(list);
            }
            catch (Exception ex)
            {
                return(list);
            }
        }
コード例 #12
0
        public CourseEntity FindById(int id)
        {
            CourseEntity course = new CourseEntity();

            try
            {
                MySqlCommand cmd = db.connection.CreateCommand();

                cmd.CommandText = "SELECT * FROM " + Constants.COURSE_TABLE_NAME + " WHERE " + Constants.COURSE_COLUMN_NAME_ID + " = " + id;

                IDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    course.Id     = reader.GetInt32(0);
                    course.UserId = reader.GetInt32(2);
                    course.Name   = reader.GetString(1);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                db.connection.Close();
            }
            return(course);
        }
コード例 #13
0
 public int Save(CourseEntity data)
 {
     try
     {
         return(Connection.Db.Query <int>("spCourseSet",
                                          new
         {
             ID = data.Id,
             TypeCourse = data.TypeCourse,
             Title = data.Title,
             DateStart = data.DateStart,
             Time = data.Time,
             Length = data.Length,
             Address = data.Address,
             TeacherId = data.TeacherId,
             Description = data.Description,
             Active = data.Active,
         }, commandType: CommandType.StoredProcedure).SingleOrDefault());
     }
     catch (Exception ex)
     {
         Tools.SaveLog.Save(ex);
         return(-1);
     }
 }
コード例 #14
0
ファイル: CourseDal.cs プロジェクト: golamambia/Development
        public static CourseEntity GetCourseById(CourseEntity courseEntity)
        {
            CourseEntity course = new CourseEntity();

            try
            {
                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandText = "dbo.CourseMasterSel";
                    command.CommandType = CommandType.StoredProcedure;
                    SqlParameter param1 = new SqlParameter("@CourseId", courseEntity.Id);
                    command.Parameters.Add(param1);
                    using (DataTable dt = DataAccess.GetData(command))
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            course = GetRow(dr);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(course);
        }
コード例 #15
0
ファイル: CourseDal.cs プロジェクト: golamambia/Development
        private static CourseEntity GetRow(DataRow dr)
        {
            CourseEntity courseEntity = new CourseEntity
            {
                Id              = DataConvert.ToInt(dr["Id"]),
                Name            = DataConvert.ToString(dr["Name"]),
                CreatedAt       = DataConvert.ToDateTime(dr["CreatedAt"]),
                CreatedByUserId = DataConvert.ToString(dr["Createdby"]),
                UpdatedAt       = DataConvert.ToDateTime(dr["UpdateAt"]),
                UpdatedByUserId = DataConvert.ToString(dr["Updateby"]),
                Description     = new DescriptionEntity
                {
                    Id              = DataConvert.ToInt(dr["DescriptionId"]),
                    CreatedAt       = DataConvert.ToDateTime(dr["DescCreatedAt"]),
                    CreatedByUserId = DataConvert.ToString(dr["DescCreatedBy"]),
                    UpdatedAt       = DataConvert.ToDateTime(dr["DescUpdateAt"]),
                    IsActive        = DataConvert.ToBoolean(dr["DescIsActive"]),
                    UpdatedByUserId = DataConvert.ToString(dr["DescUpdateBy"]),
                    Title           = DataConvert.ToString(dr["Title"]),
                    LongContent     = DataConvert.ToString(dr["LongContent"]),
                    ShortContent    = DataConvert.ToString(dr["ShortContent"])
                },
                Cuisine = new CuisineEntity
                {
                    Id   = DataConvert.ToInt(dr["CuisineId"]),
                    Name = DataConvert.ToString(dr["CuisineName"])
                },
                IsActive = DataConvert.ToBoolean(dr["IsActive"])
            };

            return(courseEntity);
        }
コード例 #16
0
ファイル: CourseDal.cs プロジェクト: golamambia/Development
        public static List <CourseEntity> GetCourse(CourseEntity courseEntity)
        {
            List <CourseEntity> courses = new List <CourseEntity>();

            try
            {
                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandText = "dbo.CourseMasterSel";
                    command.CommandType = CommandType.StoredProcedure;
                    SqlParameter param1 = new SqlParameter("@CuisineId", courseEntity.Cuisine.Id);
                    command.Parameters.Add(param1);
                    SqlParameter param2 = new SqlParameter("@CourseName", courseEntity.Name);
                    command.Parameters.Add(param2);
                    using (DataTable dt = DataAccess.GetData(command))
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            courses.Add(GetRow(dr));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(courses);
        }
コード例 #17
0
        public ActionResult UpdateCourse(string id, string txtCourse, string cbxTeacher)
        {
            CourseEntity course = new CourseEntity();

            course.id_course          = Convert.ToInt32(id);
            course.teacher.id_teacher = Convert.ToInt32(cbxTeacher);
            course.course             = txtCourse;

            String script = "";

            if (courseLogic.updateTeacher(course))
            {
                script = "<script languaje='javascript'>" +
                         "window.location.href='/Course/ListCourse'; " +
                         "</script>";
            }
            else
            {
                script = "<script languaje='javascript'>" +
                         "alert('Registro no actualizado'); " +
                         "</script>";
            }

            return(Content(script));
        }
コード例 #18
0
 public void UpdateCourse(CourseEntity updatedCourse)
 {
     if (updatedCourse.Id.Equals(Guid.Empty))
     {
         throw new ObjectNotFoundException();
     }
 }
コード例 #19
0
        public void AddUser_Test()
        {
            var user = new UserEntity()
            {
                Id         = 1,
                Name       = "Alan",
                Password   = "******",
                Type       = (int)UserType.Student,
                CreateDate = DateTime.Now,
                UpdateDate = DateTime.Now
            };

            var course = new CourseEntity()
            {
                Id          = 1,
                Name        = "C#程序设计语言",
                Description = "这是一门很炫酷的语言",
                IsOptional  = 1
            };

            using (var context = new MyCourseContext())
            {
                var users = context.User.ToList();
                //context.User.Add(user);
                //context.Course.Add(course);

                context.SaveChanges();
            }
        }
コード例 #20
0
        public void Save(CourseViewModel vm)
        {
            var entity = new CourseEntity(0);

            vm.Bind(entity);
            CourseService.Save(entity);
        }
コード例 #21
0
ファイル: CourseHelper.cs プロジェクト: yuabd/Service
 public BaseObject InsertCourse(CourseEntity param)
 {
     using (CourseLogic logic = new CourseLogic())
     {
         return(logic.InsertCourse(param));
     }
 }
コード例 #22
0
 public List <CourseEntity> Search(CourseEntity data)
 {
     try
     {
         return(Connection.Db.Query <CourseEntity>("spCourseSearch",
                                                   new
         {
             ID = data.Id,
             TypeCourse = data.TypeCourse,
             Title = "%" + data.Title + "%",
             DateStart = "%" + data.DateStart + "%",
             Time = "%" + data.Time + "%",
             Length = "%" + data.Length + "%",
             Address = "%" + data.Address + "%",
             TeacherId = data.TeacherId,
             Description = "%" + data.Description + "%",
             Active = data.Active,
         }, commandType: CommandType.StoredProcedure).ToList());
     }
     catch (Exception ex)
     {
         Tools.SaveLog.Save(ex);
         return(new List <CourseEntity>());
     }
 }
コード例 #23
0
ファイル: CourseHelper.cs プロジェクト: yuabd/Service
 public BaseObject UpdateCourse(CourseEntity param)
 {
     using (CourseLogic logic = new CourseLogic())
     {
         return(logic.UpdateCourse(param));
     }
 }
コード例 #24
0
        public bool UpdateCourse(int courseId, CourseEntity courseEntity)
        {
            var course  = _mapper.Map <CourseEntity, Course>(courseEntity);
            var success = false;

            if (courseEntity != null && course.Id == courseId)
            {
                //using (var scope = new TransactionScope())
                //{
                //var course = _unitOfWork.CourseRepository.GetByID(courseId);
                if (course != null)
                {
                    //course.Course_Name = courseEntity.Course_Name;
                    //course.App_Status = courseEntity.App_Status;
                    //course.Description = courseEntity.Description;
                    //course.Del_Status = courseEntity.Del_Status;
                    _unitOfWork.CourseRepository.Update(course);
                    _unitOfWork.Save();
                    // scope.Complete();
                    success = true;
                }
                // }
            }
            return(success);
        }
コード例 #25
0
        public Course Create(Course course)
        {
            CourseEntity courseReturn = new CourseEntity();

            courseReturn = courseDataAcces.Create(course.CourseEntityConversion());
            return(courseReturn.CourseConversion());
        }
コード例 #26
0
        public void CreateCourse_EmptyModel_ThrowsMissingInfoException()
        {
            var testClass = InteractorFactory.Create_CourseInteractor();
            var testModel = new CourseEntity();

            Should.Throw <MissingInfoException>(() => testClass.CreateCourse(testModel));
        }
コード例 #27
0
        public IActionResult Create()
        {
            var entity = new CourseEntity();

            entity.UnitPrice = 1;
            entity.Enabled   = true;
            return(View(entity));
        }
コード例 #28
0
        public static TeacherEntity ToEntity(Teacher tchr)
        {
            DbDataProvider ddp      = new DbDataProvider();
            ResourceEntity resource = ddp.GetResourceById(tchr.ResourceId);
            CourseEntity   course   = ddp.GetCourseById(tchr.CourseId);;

            return(new TeacherEntity(tchr.Id, resource, course, tchr.Notes));
        }
コード例 #29
0
        /// <summary>Creates a new, empty CourseEntity object.</summary>
        /// <returns>A new, empty CourseEntity object.</returns>
        public override IEntity Create()
        {
            IEntity toReturn = new CourseEntity();

            // __LLBLGENPRO_USER_CODE_REGION_START CreateNewCourse
            // __LLBLGENPRO_USER_CODE_REGION_END
            return(toReturn);
        }
コード例 #30
0
 public async Task Add(CourseModel model)
 {
     var courseEntity = new CourseEntity
     {
         Specialization = model.Specialization
     };
     await _repository.AddAsync(courseEntity);
 }