예제 #1
0
        public ResponseLabelLoadList LabelLoadList(RequestLabelLoadList reqparam)
        {
            var resp = new ResponseLabelLoadList();

            try
            {
                using (var dbc = new AppDbContext())
                {
                    var repo = new LabelRepository(dbc);
                    resp.Datas = new List <SVP.CIL.Domain.Label>();

                    if (reqparam.ParentTarget != null)
                    {
                        var label = repo.Load(reqparam.ParentTarget.Id);

                        foreach (var c in label.ChildLabels)
                        {
                            var domainLabel = Mapper.Map <SVP.CIL.Domain.Label>(c);
                            resp.Datas.Add(domainLabel);
                        }
                    }
                    else
                    {
                        foreach (var c in repo.FindFloatLabel())
                        {
                            var domainLabel = Mapper.Map <SVP.CIL.Domain.Label>(c);
                            resp.Datas.Add(domainLabel);
                        }
                    }

                    resp.Success = true;
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (DbEntityValidationResult entityErr in dbEx.EntityValidationErrors)
                {
                    foreach (DbValidationError error in entityErr.ValidationErrors)
                    {
                        Console.WriteLine("Error Property Name {0} : Error Message: {1}",
                                          error.PropertyName, error.ErrorMessage);
                        resp.Success = false;
                    }
                }
            }

            return(resp);
        }