public bool AddUnit(UnitMasterVM unitVM)
 {
     try
     {
         if (unitVM != null)
         {
             tblUnitMaster unit = new tblUnitMaster();
             unit.Unit         = unitVM.Unit;
             unit.UnitId       = unitVM.UnitId;
             unit.abbreviation = unitVM.abbreviation;
             unit.IsDeleted    = false;
             _UnitRepository.Add(unit);
             _unitOfWork.Complete();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#2
0
        public void Create(string description)
        {
            Unit unit = new Unit();

            unit.Description = description;
            _unitRepository.Add(unit);
        }
示例#3
0
 public Unit AddUnit(string name, string dictionaryName, IList <CustomFieldTypeId> customFieldTypeIdList, Guid transferId)
 {
     try
     {
         using (var scope = new TransactionScope())
         {
             var id   = unitRep.GetNextId();
             var unit = new Unit(id, name, dictionaryName);
             unit.TransferId = transferId;
             assignJobCustomField(unit, customFieldTypeIdList);
             unitRep.Add(unit);
             scope.Complete();
             return(unit);
         }
     }
     catch (Exception exp)
     {
         var res = unitRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
示例#4
0
        public static void CreateUnit(IUnitRepository unitRepository, string name, string dictionaryName)
        {
            var unit = new Unit(unitRepository.GetNextId(),
                                name, dictionaryName);

            unit.AssignCustomFields(DefinedCustomFields.Where(dc => dc.EntityId == EntityTypeEnum.Unit).ToList());
            unitRepository.Add(unit);
            Units.Add(unit);
        }
示例#5
0
        public Unit AssignUnit(UnitId parentId, UnitId unitId, List <SharedUnitCustomFieldId> customFieldIdList,
                               IList <UnitIndexForUnit> unitIndexList)
        {
            using (var tr = new TransactionScope())
            {
                var period     = periodRep.GetById(unitId.PeriodId);
                var sharedUnit = ipmsAdminService.GetSharedUnit(unitId.SharedUnitId);

                var sharedUnitCustomFields = ipmsAdminService.GetSharedCutomFieldListForUnit(unitId.SharedUnitId, customFieldIdList);

                var unitCustomFields = new List <UnitCustomField>();
                foreach (var sharedUnitCustomField in sharedUnitCustomFields)
                {
                    unitCustomFields.Add(new UnitCustomField(new UnitCustomFieldId(period.Id, sharedUnitCustomField.Id, unitId.SharedUnitId),
                                                             sharedUnitCustomField
                                                             ));
                }

                var unitIndexIds = unitIndexList.Select(jj => jj.UnitIndexId).ToList();
                var unitIndices  = unitIndexRep.FindUnitIndices(unitIndexIds);
                //unit.UpdateUnitIndices(unitIndices.ToList());
                var unitUnitInddices = new List <UnitUnitIndex>();
                foreach (var unitIndex in unitIndices)
                {
                    var unitindexForUnit = unitIndexList.Single(j => j.UnitIndexId == unitIndex.Id);
                    unitUnitInddices.Add(new UnitUnitIndex(unitIndex.Id, unitindexForUnit.ShowforTopLevel, unitindexForUnit.ShowforSameLevel, unitindexForUnit.ShowforLowLevel));
                }

                var parent = unitRep.GetBy(parentId);

                var unit = new Unit(period, sharedUnit, unitCustomFields, unitUnitInddices, parent);
                unitRep.Add(unit);
                tr.Complete();
                return(unit);
            }
        }
示例#6
0
        public static Unit CreateUnit(IUnitRepository unitRepository, PMSAdmin.Domain.Model.Units.Unit adminUnit, Unit parentUnit, Dictionary <string, string> indexValue)
        {
            var unitCustomFields =
                AdminMigrationUtility.DefinedCustomFields.Where(d => adminUnit.CustomFieldTypeIdList.Contains(d.Id))
                .Select(
                    c =>
                    new UnitCustomField(
                        new UnitCustomFieldId(Period.Id, new SharedUnitCustomFieldId(c.Id.Id),
                                              new SharedUnitId(adminUnit.Id.Id)),
                        new SharedUnitCustomField(new SharedUnitCustomFieldId(c.Id.Id), c.Name, c.DictionaryName,
                                                  c.MinValue, c.MaxValue, c.TypeId))).ToList();
            var unitUnitIndices = unitIndices.Select(j => new UnitUnitIndex(j.Id, true, true, true)).ToList();
            var unit            = new Unit(Period, new SharedUnit(new SharedUnitId(adminUnit.Id.Id), adminUnit.Name, adminUnit.DictionaryName), unitCustomFields, unitUnitIndices, parentUnit);

            unitRepository.Add(unit);
            Units.Add(unit, indexValue);
            return(unit);
        }
示例#7
0
 public Task <object> Handle(AddNewUnitCommand command, CancellationToken cancellationToken)
 {
     Entities.Unit u = new Entities.Unit(null, new Name(command.Name));
     if (!command.IsValid())
     {
         NotifyValidationErrors(command);
     }
     else
     {
         UnitModel model = _unitRepository.Add(u);
         if (model != null)
         {
             return(Task.FromResult(model as object));
         }
         _bus.RaiseEvent(new DomainNotification("Unit", "Server error", NotificationCode.Error));
     }
     return(Task.FromResult(null as object));
 }
示例#8
0
        /// <summary>
        /// Add new Tax value
        /// </summary>
        /// <param name="obj">Tax value</param>
        /// <returns></returns>
        public ApiResponseViewModel Add(Unit obj)
        {
            var result   = new Unit();
            var response = new ApiResponseViewModel
            {
                Code    = CommonConstants.ApiResponseSuccessCode,
                Message = null,
                Result  = null
            };

            try
            {
                result = _unitRepository.Add(obj);
                _unitOfWork.Commit();
                response.Message = CommonConstants.AddSuccess;
                response.Result  = result;
            }
            catch (Exception ex)
            {
                response.Code    = CommonConstants.ApiResponseExceptionCode;
                response.Message = CommonConstants.ErrorMessage + " " + ex.Message;
            }
            return(response);
        }
        public void Add(Unit entity)

        {
            _unitrepository.Add(entity);
            SaveChanges();
        }
示例#10
0
 public Unit Add(Unit Unit)
 {
     return(_UnitRepository.Add(Unit));
 }
示例#11
0
 public void Add(UnitDTO entity)
 {
     _unitRepository.Add(entity);
 }
示例#12
0
 public Unit Add(Unit unit)
 {
     return(_unitRepository.Add(unit));
 }
示例#13
0
        public void Add(UnitViewModel unitVm)
        {
            var unit = Mapper.Map <UnitViewModel, Unit>(unitVm);

            _unitRepository.Add(unit);
        }
示例#14
0
 public void AddUnitModel(UnitModel model)
 {
     _unitRepository.Add(model);
     _unitRepository.Save();
 }
示例#15
0
 public void Add(Unit entity)
 {
     unitRepository.Add(entity);
 }
示例#16
0
 public void createunit(UnitMaster unitmaster)
 {
     _iunitmasterrepository.Add(unitmaster);
     _unitofwork.Commit();
 }