예제 #1
0
        /// <summary>
        /// 修改行政区划信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public ActionResult UpdateRegion(RegionOperateDTO dto)
        {
            UserLoginDTO user = (UserLoginDTO)Session["UserLoginInfo"];

            dto.ModifyUser = user.FullName;
            dto.ModifyTime = DateTime.Now;
            var result = AreaRegionProvider.UpdateRegion(dto);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        /// <summary>
        /// 修改行政区划信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public static ResultData <object> UpdateRegion(RegionOperateDTO dto)
        {
            var result = new ResultData <object>();

            try
            {
                result = PutAPI <ResultData <object> >(WebConfiger.MasterDataServicesUrl + "Region", dto);
                GlobalStaticData.RegionList = GetAPI <List <RegionResultDTO> >(WebConfiger.MasterDataServicesUrl + "Region");
            }
            catch (Exception e)
            {
                result.Message = e.Message;
            }

            return(result);
        }
예제 #3
0
        /// <summary>
        /// 新增行政区划
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public bool AddRegion(RegionOperateDTO dto)
        {
            var result = false;

            using (var tcdmse = new Entities.TCDMS_MasterDataEntities())
            {
                var dumplicated = tcdmse.dict_RegionInfo.AsNoTracking().Where(p => p.RegionPID == dto.RegionPID && p.RegionName == dto.RegionName).FirstOrDefault();
                if (dumplicated != null)
                {
                    throw new Exception("新增行政区域不可同名!");
                }
                var newregion = new dict_RegionInfo();
                newregion = Mapper.Map <RegionOperateDTO, dict_RegionInfo>(dto);
                tcdmse.dict_RegionInfo.Add(newregion);
                result = tcdmse.SaveChanges() > 0;
            }

            return(result);
        }
예제 #4
0
        /// <summary>
        /// 修改行政区划信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public bool UpdateRegion(RegionOperateDTO dto)
        {
            var result = false;

            using (var tcdmse = new Entities.TCDMS_MasterDataEntities())
            {
                var pp = tcdmse.dict_RegionInfo.Where(p => p.RegionID == dto.RegionID).FirstOrDefault();
                if (pp == null)
                {
                    throw new Exception("此条信息不存在!");
                }
                var dumplicated = tcdmse.dict_RegionInfo.AsNoTracking().Where(p => p.RegionPID == dto.RegionPID && p.RegionID != dto.RegionID && p.RegionName == dto.RegionName).FirstOrDefault();
                if (dumplicated != null)
                {
                    throw new Exception("修改行政区域不可同名!");
                }
                Mapper.Map <RegionOperateDTO, dict_RegionInfo>(dto, pp);
                result = tcdmse.SaveChanges() > 0;
            }

            return(result);
        }
예제 #5
0
        public HttpResponseMessage UpdateRegion(RegionOperateDTO dto)
        {
            ResultDTO <object> actionresult = new ResultDTO <object>();

            try
            {
                actionresult.SubmitResult = _IRegionServices.UpdateRegion(dto);
            }
            catch (Exception ex)
            {
                actionresult.SubmitResult = false;
                actionresult.Message      = ex.Message;
            }
            HttpResponseMessage result = new HttpResponseMessage
            {
                Content = new StringContent(JsonConvert.SerializeObject(actionresult),
                                            System.Text.Encoding.GetEncoding("UTF-8"),
                                            "application/json")
            };

            return(result);
        }