示例#1
0
        public IActionResult UpdateSkillFreelance(int id, int[] skills)
        {
            var _FreelanceSkill = _context.FreelanceSkill.Where(p => p.Freelance_ID == id).ToArray();

            if (_FreelanceSkill.Length == 0)
            {
                foreach (var skillLists in skills)
                {
                    var _Skill = new FreelanceSkill
                    {
                        Skill_ID     = skillLists,
                        Freelance_ID = id,
                        Date_Create  = DateTime.Now,
                        Date_Update  = DateTime.Now,
                        DelStatus    = false,
                    };
                    _context.FreelanceSkill.Add(_Skill);
                    _context.SaveChanges();
                }
            }
            else
            {
                foreach (var _SkillFreelance in _FreelanceSkill)
                {
                    _context.FreelanceSkill.Remove(_SkillFreelance);
                    _context.SaveChanges();
                }
                foreach (var skillLists in skills)
                {
                    var _FreelanceSkillList = new FreelanceSkill
                    {
                        Skill_ID     = skillLists,
                        Freelance_ID = id,
                        Date_Create  = DateTime.Now,
                        Date_Update  = DateTime.Now,
                        DelStatus    = false,
                    };
                    _context.FreelanceSkill.Add(_FreelanceSkillList);
                    _context.SaveChanges();
                }
            }
            var Results = new { id, skills };

            return(Json(new { Result = "OK" }));
        }
示例#2
0
        public IActionResult UpdateFreelanceSkill(int[] skillList, int id)
        {
            foreach (var skillLists in skillList)
            {
                var _FreelanceSkill = new FreelanceSkill
                {
                    Skill_ID     = skillLists,
                    Freelance_ID = id,
                    Date_Create  = DateTime.Now,
                    Date_Update  = DateTime.Now,
                    DelStatus    = false,
                };
                _context.FreelanceSkill.Add(_FreelanceSkill);
                _context.SaveChanges();
            }

            return(Json(new { Result = skillList, idferrlance = id }));
        }
示例#3
0
        public IActionResult FreelanceRegister(Freelance Freelance, int[] skillList)
        {
            var _Freelance = new Freelance
            {
                UserName        = Freelance.UserName,
                Password        = Freelance.Password,
                FullName        = Freelance.FullName,
                TelephoneNumber = Freelance.TelephoneNumber,
                ID_Card         = Freelance.ID_Card,
                Email           = Freelance.Email,
                Facebook        = Freelance.Facebook,
                Line            = Freelance.Line,
                Address         = Freelance.Address,
                ImgName         = "defaultImg.jpg",
                Date_Create     = DateTime.Now,
                Date_Update     = DateTime.Now,
                DelStatus       = false,
            };

            _context.Add(_Freelance);
            _context.SaveChanges();
            int id = _Freelance.Freelance_ID;

            foreach (var skillLists in skillList)
            {
                var _FreelanceSkill = new FreelanceSkill
                {
                    Skill_ID     = skillLists,
                    Freelance_ID = id,
                    Date_Create  = DateTime.Now,
                    Date_Update  = DateTime.Now,
                    DelStatus    = false,
                };
                _context.FreelanceSkill.Add(_FreelanceSkill);
                _context.SaveChanges();
            }
            return(Json(new { Result = _Freelance, skillList = skillList }));
        }