Exemplo n.º 1
0
 public void Remove(CareerPath job)
 {
     if (Context.Entry(job).State == EntityState.Detached)
     {
         context.CareerPathes.Attach(job);
     }
     context.CareerPathes.Remove(job);
 }
Exemplo n.º 2
0
        public ActionResult CreateCareerPath(IEnumerable <CareerPathViewModel> models, OptionsViewModel moreInfo)
        {
            var result     = new List <CareerPath>();
            var datasource = new DataSource <CareerPathViewModel>();

            if (ModelState.IsValid)
            {
                if (ServerValidationEnabled)
                {
                    var errors = _hrUnitOfWork.LookUpRepository.Check(new CheckParm
                    {
                        CompanyId    = CompanyId,
                        ObjectName   = "CareerPaths",
                        TableName    = "CareerPaths",
                        ParentColumn = "CompanyId",
                        Columns      = Models.Utils.GetModifiedRows(ModelState),
                        Culture      = Language
                    });

                    if (errors.Count() > 0)
                    {
                        datasource.Errors = errors;
                        return(Json(datasource));
                    }
                }
                foreach (CareerPathViewModel c in models)
                {
                    var Path = new CareerPath();
                    AutoMapper(new Models.AutoMapperParm
                    {
                        Destination = Path,
                        Source      = c,
                        ObjectName  = "CareerPaths",
                        Options     = moreInfo,
                        Transtype   = TransType.Insert
                    });

                    if (c.StartDate > c.EndDate)
                    {
                        ModelState.AddModelError("EndDate", MsgUtils.Instance.Trls("EndMustGrtThanStart"));
                        datasource.Errors = Models.Utils.ParseErrors(ModelState.Values);
                        return(Json(datasource));
                    }
                    result.Add(Path);
                    Path.CompanyId = Path.IsLocal ? CompanyId : (int?)null;
                    _hrUnitOfWork.JobRepository.Add(Path);
                }

                datasource.Errors = SaveChanges(Language);
            }

            else
            {
                datasource.Errors = Models.Utils.ParseErrors(ModelState.Values);
            }

            datasource.Data = (from model in models
                               join r in result on model.Name equals r.Name into g
                               from r in g.DefaultIfEmpty()
                               select new CareerPathViewModel
            {
                Id = (r == null ? 0 : r.Id),
                Code = model.Code,
                Name = model.Name,
                IsLocal = model.IsLocal,
                StartDate = model.StartDate,
                Description = model.Description,
                EndDate = model.EndDate,
            }).ToList();

            if (datasource.Errors.Count() > 0)
            {
                datasource.Data = models;
                return(Json(datasource));
            }
            else
            {
                return(Json(datasource.Data));
            }
        }
Exemplo n.º 3
0
 public DbEntityEntry <CareerPath> Entry(CareerPath careerPath)
 {
     return(Context.Entry(careerPath));
 }
Exemplo n.º 4
0
 public void Attach(CareerPath careerpath)
 {
     context.CareerPathes.Attach(careerpath);
 }
Exemplo n.º 5
0
 public void Add(CareerPath job)
 {
     context.CareerPathes.Add(job);
 }