Exemple #1
0
        public IHttpActionResult Post(DC_TeamActivitydtlModel baseRequest)
        {
            baseRequest.ORGID = SecurityHelper.CurrentPrincipal.OrgId;

            var response = service.SaveTeamActivitydtl(baseRequest);

            return(Ok(response));
        }
        //保存数据字典主表
        public BaseResponse <DC_TeamActivitydtlModel> SaveTeamActivitydtl(DC_TeamActivitydtlModel request)
        {
            //---

            BaseResponse <DC_TeamActivitydtlModel> responsePerson = new BaseResponse <DC_TeamActivitydtlModel>();

            Mapper.CreateMap <DC_TeamActivitydtlModel, DC_TEAMACTIVITYDTL>();

            var model = unitOfWork.GetRepository <DC_TEAMACTIVITYDTL>().dbSet.Where(m => m.ID == request.ID).FirstOrDefault();

            if (model == null)
            {
                var act = unitOfWork.GetRepository <DC_TEAMACTIVITY>().dbSet.Where(m => m.ORGID == request.ORGID && m.ACTIVITYCODE == request.ACTIVITYCODE).ToList().FirstOrDefault().SEQNO;
                request.SEQNO = act;
                model         = Mapper.Map <DC_TEAMACTIVITYDTL>(request);

                unitOfWork.GetRepository <DC_TEAMACTIVITYDTL>().Insert(model);
                unitOfWork.Save();
            }
            else
            {
                var act = unitOfWork.GetRepository <DC_TEAMACTIVITY>().dbSet.Where(m => m.ORGID == request.ORGID && m.ACTIVITYCODE == request.ACTIVITYCODE).ToList().FirstOrDefault().SEQNO;
                request.SEQNO = act;

                Mapper.Map(request, model);

                unitOfWork.GetRepository <DC_TEAMACTIVITYDTL>().Update(model);
            }
            unitOfWork.Save();

            return(responsePerson);
            //--



            //unitOfWork.BeginTransaction();
            //responsePerson = base.Save<DC_TEAMACTIVITYDTL, DC_TeamActivitydtlModel>(request, (q) => q.ID == request.ID);

            //unitOfWork.Commit();
            //return responsePerson;
        }