public bool Insert(OfferJobSkill of)
 {
     try
     {
         db.OfferJobSkills.Add(of);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
示例#2
0
        public ActionResult AddOfferOfEmployee(FormOffer model)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Account"));
            }
            var accID    = int.Parse(User.Identity.Name);
            var acc      = new AccountDao().FindAccountById(accID);
            var emp      = new EmployeeDao().FindById(acc.UserId);
            var offerJob = new OfferJob();

            if (model.typeAction == "add")
            {
                offerJob.OfferID         = Guid.NewGuid();
                offerJob.OfferCreateDate = DateTime.Now;
                offerJob.Views           = 0;
                offerJob.Applications    = 0;
            }
            else
            {
                offerJob.OfferID = model.saveID;
            }
            offerJob.EmployeeID   = acc.UserId;
            offerJob.EnterpriseID = emp.EnterpriseID;
            offerJob.OfferName    = model.offerName;
            if (model.offerDescription != null && model.offerDescription != "")
            {
                offerJob.OfferDescription = model.offerDescription;
            }
            offerJob.OfferMajor           = model.offerMajor;
            offerJob.OfferPosition        = model.offerPosition;
            offerJob.OfferSalary          = model.offerSalary;
            offerJob.Area                 = model.offerArea;
            offerJob.Amount               = model.offerAmount;
            offerJob.ExperienceRequest    = model.offerExperience;
            offerJob.ContactEmail         = model.offerEmail;
            offerJob.LearningLevelRequest = model.offerLearning;
            offerJob.OfferLimitDate       = DateTime.ParseExact(model.offerLimitDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            if (model.offerGender != "none")
            {
                offerJob.Sex = model.offerGender;
            }
            offerJob.JobAddress = model.offerAddress;
            var file = model.offerImage;

            if (file != null)
            {
                var fileName = Path.GetFileName(file.FileName);
                file.SaveAs(Server.MapPath("/Assets/Client/Img/Offer/" + fileName));
                var srcImage = "/Assets/Client/Img/Offer/" + fileName;
                offerJob.OfferImage = srcImage;
            }
            if (model.typeAction == "add")
            {
                var check = new OfferJobDao().Insert(offerJob);
            }
            else
            {
                var check = new OfferJobDao().Edit(offerJob);
            }
            if (model.offerListSkillId != null && model.offerListSkillId.Count > 0)
            {
                for (var i = 0; i < model.offerListSkillId.Count; i++)
                {
                    var offerSkill = new OfferJobSkill();
                    offerSkill.OfferID     = offerJob.OfferID;
                    offerSkill.ParentMajor = model.offerListSkillParent[i];
                    offerSkill.ChildMajor  = model.offerListSkillId[i];
                    var checkFalse = new OfferJobSkillDao().Insert(offerSkill);
                    if (!checkFalse)
                    {
                        break;
                    }
                }
            }
            return(RedirectToAction("ListAndCreateOffer", "Employee"));
        }