Ejemplo n.º 1
0
        /// <summary>
        /// 将ModuleDb的内容复制到LevelModuleViewModel中
        /// </summary>
        /// <param name="module">ModuleDb</param>
        /// <returns></returns>
        public LevelModuleViewModel IniModuleView(ModuleDb module)
        {
            var view = new LevelModuleViewModel();

            ModelCopier.CopyModel(module, view, "SonList");
            return(view);
        }
Ejemplo n.º 2
0
        public ActionResult SaveMulti(SubmitModel model)
        {
            SessionHelper.Temp  = model.DistrictId;
            SessionHelper.Temp2 = model.UpazillaId;

            foreach (var v in model.MultiDatas)
            {
                if (v.Count > 0)
                {
                    SummerizedData entity = new SummerizedData();

                    ModelCopier.CopyModel(model, entity);

                    entity.InsertedById = SessionHelper.UserId;
                    entity.SourceId     = v.Id;
                    entity.ReachCount   = v.Count;
                    entity.CollectedBy  = v.CollectedBy;

                    if (entity.Id > 0)
                    {
                        sunDataService.Update(entity);
                    }
                    else
                    {
                        sunDataService.Add(entity);
                    }
                }
            }

            unitOfWork.Commit();

            return(PartialView("Save"));
        }
        public ActionResult CreateDetail(DistrictSubmitSubModel model)
        {
            DistrictSubmitModel up = new DistrictSubmitModel();

            var disData = disDataService.Get(model.DistrictId, model.Date);
            var sumData = disDataService.GetSummery(model.DistrictId);

            ModelCopier.CopyModel(disData, up);
            ModelCopier.CopyModel(sumData, up);

            if (disData != null)
            {
                up.DetailId      = disData.Id;
                up.RemarksDetail = disData.Remarks;
            }

            if (sumData != null)
            {
                up.SumId      = sumData.Id;
                up.RemarksSum = sumData.Remarks;
            }

            up.Date         = model.Date;
            up.DivisionName = standingDataService.GetDataById(model.DivisionId).Name;

            var dis = standingDataService.GetDataById(model.DistrictId);

            up.DistrictName      = dis.Name;
            up.DistrictTypeValue = dis.IntValue ?? 0;

            return(PartialView(up));
        }
Ejemplo n.º 4
0
        public Message CreateMessage(Message mesage)
        {
            var createRequest = new MessageCreateRequest();

            ModelCopier.CopyModel(mesage, createRequest);
            return(Api.Messages.Create(createRequest));
        }
Ejemplo n.º 5
0
        public ActionResult Save(UserProfileModel model)
        {
            var login = service.GetByPin(model.Pin);

            if (login != null)
            {
                model.Roles = roleService.GetAll().ToSelectList(null, "Id", "RoleName");

                ModelState.AddModelError("", "User has exists");
                return(PartialView("Create", model));
            }

            model.Password = "" + model.Password.ToMD5();

            UserProfile entity = new UserProfile();

            ModelCopier.CopyModel(model, entity);

            service.Add(entity);

            unitOfWork.Commit();
            SessionHelper.Temp = null;

            return(PartialView());
        }
        public void Update(DictionaryTypeTableDb model)
        {
            DictionaryTypeTableDb tempModel = PermissionDal.GetModel(c => c.dt_type_key == model.dt_type_key);

            ModelCopier.CopyModel(model, tempModel, "creator_name", "creator_date");
            PermissionDal.SaveChanges();
        }
Ejemplo n.º 7
0
        public ActionResult Save(SubmitModel model)
        {
            SessionHelper.Temp  = model.DistrictId;
            SessionHelper.Temp2 = model.UpazillaId;
            SessionHelper.Temp3 = model.CollectedBy;
            SessionHelper.Temp4 = model.SourceId;


            DetailData entity = new DetailData();

            ModelCopier.CopyModel(model, entity);

            entity.InsertedById = SessionHelper.UserId;

            if (model.Id == 0)
            {
                sunDataService.Add(entity);
            }
            else
            {
                sunDataService.Update(entity);
            }

            unitOfWork.Commit();

            return(PartialView());

            //return PartialView("Create",GetModel(model.CollectedBy));
        }
Ejemplo n.º 8
0
 public ActionResult Detail(DictionaryWebM model, bool isEdit)
 {
     if (ModelState.IsValid)
     {
         model.dt_key = model.dt_key.Trim();
         DictionaryTableDb dbModel = new DictionaryTableDb();
         ModelCopier.CopyModel(model, dbModel);
         if (isEdit)
         {
             dbModel.modifi_name = LoginUser.user_name;
             dbModel.modifi_date = DateTime.Now;
             DictionaryTableBll.Instance.Update(dbModel);
             return(Content("<script>alert('修改字典成功!');parent.layer.closeAll('iframe');</script>"));
         }
         else
         {
             dbModel.creator_name = LoginUser.user_name;
             dbModel.creator_date = DateTime.Now;
             DictionaryTableBll.Instance.Add(dbModel);
             return(Content("<script>alert('添加字典成功!');parent.layer.closeAll('iframe');</script>"));
         }
     }
     ViewBag.EditType = isEdit;
     return(View(model));
 }
Ejemplo n.º 9
0
        public static CompanyRegisterViewModel Dto(this CompanyRegister o)
        {
            var viewMode = new CompanyRegisterViewModel();

            ModelCopier.CopyModel(o, viewMode);
            viewMode.CompanyRegisterId = o.CompanyRegisterId;
            if (o.CorpBaseInfoId != null)
            {
                viewMode.CorpBaseInfoId   = o.CorpBaseInfoId;
                viewMode.CorpBaseInfoName = o.CorpBaseInfoName;
            }
            else
            {
                viewMode.CorpBaseInfoId   = o.CorpBaseInfoId;
                viewMode.CorpBaseInfoName = o.CorpBaseInfoOther;
            }
            viewMode.SN                 = o.SN;
            viewMode.Creator            = o.Creator;
            viewMode.CreatorDisplayName = o.StartUser.DisplayName;
            viewMode.CreatedTime        = o.CreatedTime.ToString("yyyy-MM-dd");
            viewMode.ModifyName         = o.Creator;
            viewMode.ModifyDisplayName  = o.StartUser.DisplayName;
            viewMode.ModifyTime         = o.ModifyTime.ToString("yyyy-MM-dd");
            IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();

            //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
            timeConverter.DateTimeFormat       = "yyyy'-'MM'-'dd";
            viewMode.CompanyRegisterRecordJson = JsonConvert.SerializeObject(o.CompanyRegisterRecords, timeConverter);
            return(viewMode);
        }
Ejemplo n.º 10
0
        public virtual async Task <D> Update(Guid id, D model, Guid?userId = null, bool isCommit = true)
        {
            try
            {
                Guid _userId = userId == null ? Guid.Empty : userId.Value;

                D oldRec = await Repository.GetByID(id);

                if (Validation.IsNull(oldRec))
                {
                    return(null);
                }

                ModelCopier.CopyModel(model, oldRec);

                if (oldRec is ITableEntity)
                {
                    (oldRec as ITableEntity).UpdateBy       = _userId;
                    (oldRec as ITableEntity).UpdateDateTime = DateTime.Now;
                }

                Repository.Update(oldRec);

                if (isCommit)
                {
                    await Commit();
                }

                return(oldRec);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 11
0
        public void Update(RoleDb model, List <RoleModuleRelationDb> roleModuleRelations)
        {
            using (var db = PermissionDal.DbContext)
            {
                using (var dbContextTransaction = PermissionDal.DbContext.Database.BeginTransaction()) //起一个事务
                {
                    try
                    {
                        RoleDb tempModel = PermissionDal.GetModel(c => c.role_id == model.role_id);

                        ModelCopier.CopyModel(model, tempModel, "creator_name",
                                              "creator_full_name", "creator_time");
                        PermissionDal.EditData(tempModel);
                        PermissionDal.DbContext.Database.ExecuteSqlCommand(" delete from role_module_relation where role_id=@p0 ", model.role_id);
                        PermissionDal.AddList(roleModuleRelations);
                        PermissionDal.DbContext.SaveChanges();
                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                    finally
                    {
                        PermissionDal.DbContextDispose();
                    }
                }
            }
        }
Ejemplo n.º 12
0
        public ActionResult Save(RoleModel model)
        {
            try
            {
                Role entity = new Role();

                ModelCopier.CopyModel(model, entity);


                if (model.Id == 0)
                {
                    roleService.Add(entity);
                }
                else
                {
                    roleService.Update(entity);
                }

                unitOfWork.Commit();

                return(PartialView());
            }
            catch
            {
                return(RedirectToAction("Error", "Main"));
            }
        }
Ejemplo n.º 13
0
        public CalendarEventStub CreateCalendarEvent(CalendarEventStub calendarEvent)
        {
            var createRequest = new CalendarEventCreateRequest();

            ModelCopier.CopyModel(calendarEvent, createRequest);
            return(Api.Calendars.CreateEventForProject(this.Id, createRequest));
        }
Ejemplo n.º 14
0
        public void Update(ModuleDb model)
        {
            ModuleDb tempModel = PermissionDal.GetModel(c => c.module_code == model.module_code);

            ModelCopier.CopyModel(model, tempModel, "parent_code", "module_level", "creator_name", "creator_date");
            PermissionDal.SaveChanges();
        }
Ejemplo n.º 15
0
        public ActionResult Details(int id)
        {
            UserProfile      entity = service.GetDataById(id);
            UserProfileModel model  = new UserProfileModel();

            ModelCopier.CopyModel(entity, model);
            return(PartialView(model));
        }
Ejemplo n.º 16
0
        public static CompanyRegisterRecordViewModel Dto(this CompanyRegisterRecord o)
        {
            var viewMode = new CompanyRegisterRecordViewModel();

            ModelCopier.CopyModel(o, viewMode);
            viewMode.CreatedTime = o.CreatedTime.ToString("yyyy-MM-dd");
            return(viewMode);
        }
Ejemplo n.º 17
0
        public static CompanyRegisterChangeRecordViewModel Dto(this CompanyRegistersChangeRecord o)
        {
            var viewMode = new CompanyRegisterChangeRecordViewModel();

            ModelCopier.CopyModel(o, viewMode);
            //viewMode.EditTime = o.EditTime.ToString("yyyy-MM-dd");
            return(viewMode);
        }
Ejemplo n.º 18
0
        public ActionResult Edit(int Id)
        {
            var entity = standingDataService.GetDataById(Id);

            StandingDataModel model = new StandingDataModel();

            ModelCopier.CopyModel(entity, model);

            return(PartialView("Create", model));
        }
Ejemplo n.º 19
0
 public ActionResult Add(AdminUserWebM model)
 {
     if (ModelState.IsValid && model != null)
     {
         AdminUserDb adminUserDb = new AdminUserDb();
         model.user_name = model.user_name.Trim();
         ModelCopier.CopyModel(model, adminUserDb);
         AdminUserBll.Instance.Add(adminUserDb, model.role_ids);
         return(Content("<script>alert('添加用户成功!');parent.layer.closeAll('iframe');</script>"));
     }
     return(View(model));
 }
Ejemplo n.º 20
0
        public ActionResult Edit(int Id)
        {
            var entity = service.GetDataById(Id);

            ViewBag.RoleId = new SelectList(roleService.GetAll(), "Id", "RoleName", entity.RoleId);

            UserProfileModel model = new UserProfileModel();

            ModelCopier.CopyModel(entity, model);

            return(PartialView("Create", model));
        }
Ejemplo n.º 21
0
        public void CopyModel_ToIsNull_DoesNothing()
        {
            // Arrange
            GenericModel <int> from = new GenericModel <int> {
                TheProperty = 21
            };
            GenericModel <int> to = null;

            // Act
            ModelCopier.CopyModel(from, to);

            // Assert
            Assert.Equal(21, from.TheProperty);
        }
Ejemplo n.º 22
0
        public void CopyModel_FromIsNull_DoesNothing()
        {
            // Arrange
            GenericModel <int> from = null;
            GenericModel <int> to   = new GenericModel <int> {
                TheProperty = 42
            };

            // Act
            ModelCopier.CopyModel(from, to);

            // Assert
            Assert.Equal(42, to.TheProperty);
        }
Ejemplo n.º 23
0
        public ActionResult Edit(EditUserModel model)
        {
            try {
                User user = _repository.GetUser(model.UserName);
                ModelCopier.CopyModel(model, user);
                _repository.Update(user);

                return(RedirectToAction("Details", new { id = model.UserName }));
            } catch (Exception) {
                ModelState.AddModelError("", "Edit Failure, see inner exception.");
            }

            return(View(model));
        }
Ejemplo n.º 24
0
        public void CopyModel_ToIsReadOnly_DoesNothing()
        {
            // Arrange
            GenericModel <int> from = new GenericModel <int> {
                TheProperty = 21
            };
            ReadOnlyGenericModel <int> to = new ReadOnlyGenericModel <int>(42);

            // Act
            ModelCopier.CopyModel(from, to);

            // Assert
            Assert.Equal(21, from.TheProperty);
            Assert.Equal(42, to.TheProperty);
        }
Ejemplo n.º 25
0
        public ActionResult Edit(string id)
        {
            User user = _repository.GetUser(id);

            if (user == null)
            {
                return(RedirectToAction("Index"));
            }

            EditUserModel model = new EditUserModel();

            ModelCopier.CopyModel(user, model);

            return(View(model));
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Detail(string key = "")
        {
            DictionaryWebM webModel = new DictionaryWebM();

            if (string.IsNullOrEmpty(key))
            {
                ViewBag.EditType = false;
            }
            else
            {
                ViewBag.EditType = true;
                DictionaryTableDb model = DictionaryTableBll.Instance.GetModel(key);
                ModelCopier.CopyModel(model, webModel);
            }
            return(View(webModel));
        }
Ejemplo n.º 27
0
        public void CopyModel_LiftedTypeMatch_ActualValueIsNull_DoesNothing()
        {
            // Arrange
            GenericModel <int?> from = new GenericModel <int?> {
                TheProperty = null
            };
            GenericModel <int> to = new GenericModel <int> {
                TheProperty = 42
            };

            // Act
            ModelCopier.CopyModel(from, to);

            // Assert
            Assert.Null(from.TheProperty);
            Assert.Equal(42, to.TheProperty);
        }
Ejemplo n.º 28
0
        public void CopyModel_NoTypeMatch_DoesNothing()
        {
            // Arrange
            GenericModel <int> from = new GenericModel <int> {
                TheProperty = 21
            };
            GenericModel <long> to = new GenericModel <long> {
                TheProperty = 42
            };

            // Act
            ModelCopier.CopyModel(from, to);

            // Assert
            Assert.Equal(21, from.TheProperty);
            Assert.Equal(42, to.TheProperty);
        }
Ejemplo n.º 29
0
        public void CopyModel_ToDoesNotContainProperty_DoesNothing()
        {
            // Arrange
            GenericModel <int> from = new GenericModel <int> {
                TheProperty = 21
            };
            OtherGenericModel <int> to = new OtherGenericModel <int> {
                SomeOtherProperty = 42
            };

            // Act
            ModelCopier.CopyModel(from, to);

            // Assert
            Assert.Equal(21, from.TheProperty);
            Assert.Equal(42, to.SomeOtherProperty);
        }
Ejemplo n.º 30
0
        public void CopyModel_ExactTypeMatch_Copies()
        {
            // Arrange
            GenericModel <int> from = new GenericModel <int> {
                TheProperty = 21
            };
            GenericModel <int> to = new GenericModel <int> {
                TheProperty = 42
            };

            // Act
            ModelCopier.CopyModel(from, to);

            // Assert
            Assert.Equal(21, from.TheProperty);
            Assert.Equal(21, to.TheProperty);
        }