コード例 #1
0
        /// <summary>
        /// Store the label to the database and sets the default criteria string only if the id is 0.
        /// Otherwise just return a the record.
        /// </summary>
        /// <param name="labels">The label check if its new.</param>
        /// <param name="modifyUser">the user to log as the created or modified user</param>
        /// <param name="_repository">repository used for saving info</param>
        /// <returns></returns>
        private ApptLabelDto StoreLabel(ApptLabelDto label, string modifyUser, IDataRepositoryCrudBase <ApptLabel> _repository)
        {
            ApptLabel lbl = label.ConvertTo <ApptLabel>();

            if (label.Id == 0)
            {
                //then save the label, to get an ID,
                lbl = _repository.CreateUpdate(lbl, modifyUser);
                //then but also set the criteria to the correct value and save it again..
                if (Type.GetType(lbl.UseInterfaceType) == typeof(IEntityWithStatusLabels))
                {
                    lbl.LabelCriteria = $"([LabelKey] = '{lbl.Id}')";
                }
            }
            return(_repository.CreateUpdate(lbl, modifyUser).ConvertTo <ApptLabelDto>());
        }
コード例 #2
0
ファイル: ApptStatusService.cs プロジェクト: CobyC/JaRS
        private ApptStatusDto StoreStatus(ApptStatusDto status, string modifyUser, IDataRepositoryCrudBase <ApptStatus> _repository)
        {
            ApptStatus sts = status.ConvertTo <ApptStatus>();

            if (sts.Id == 0)
            {
                //then save the label, to get an ID,
                sts = _repository.CreateUpdate(sts, modifyUser);
                //then but also set the criteria to the correct value and save it again..
                if (Type.GetType(sts.UseInterfaceType) == typeof(IEntityWithStatusLabels))
                {
                    sts.StatusCriteria = $"([{nameof(IEntityWithStatusLabels.StatusKey)}] = '{sts.Id}')";
                }
            }
            return(_repository.CreateUpdate(sts, modifyUser).ConvertTo <ApptStatusDto>());
        }
コード例 #3
0
        /// <summary>
        /// Store the label to the database and sets the default criteria string only if the id is 0.
        /// Otherwise just return a the record.
        /// </summary>
        /// <param name="labels">The label check if its new.</param>
        /// <param name="modifyUser">the user to log as the created or modified user</param>
        /// <param name="_repository">repository used for saving info</param>
        /// <returns></returns>
        private List <ApptLabelDto> StoreLabels(List <ApptLabelDto> labels, string modifyUser, IDataRepositoryCrudBase <ApptLabel> _repository)
        {
            List <ApptLabel> saveList = new List <ApptLabel>();

            foreach (var label in labels)
            {
                ApptLabel lbl = label.ConvertTo <ApptLabel>();
                if (label.Id == 0)
                {
                    //then save the label, to get an ID,
                    lbl = _repository.CreateUpdate(lbl, modifyUser);
                    //then but also set the criteria to the correct value and save it again..
                    if (Type.GetType(lbl.UseInterfaceType) == typeof(IEntityWithStatusLabels))
                    {
                        lbl.LabelCriteria = $"([LabelKey] = '{lbl.Id}')";
                    }
                }
                saveList.Add(lbl);
            }
            return(_repository.CreateUpdateList(saveList, modifyUser).ConvertAllTo <ApptLabelDto>().ToList());
        }
コード例 #4
0
ファイル: ApptStatusService.cs プロジェクト: CobyC/JaRS
        private List <ApptStatusDto> StoreStatuses(List <ApptStatusDto> statuses, string modifyUser, IDataRepositoryCrudBase <ApptStatus> _repository)
        {
            List <ApptStatus> saveList = new List <ApptStatus>();

            foreach (var status in statuses)
            {
                ApptStatus sts = status.ConvertTo <ApptStatus>();
                if (sts.Id == 0)
                {
                    //then save the label, to get an ID,
                    sts = _repository.CreateUpdate(sts, modifyUser);
                    //then but also set the criteria to the correct value and save it again..
                    if (Type.GetType(sts.UseInterfaceType) == typeof(IEntityWithStatusLabels))
                    {
                        sts.StatusCriteria = $"([{nameof(IEntityWithStatusLabels.StatusKey)}] = '{sts.Id}')";
                    }
                }
                saveList.Add(sts);
            }
            return(_repository.CreateUpdateList(saveList, modifyUser).ConvertAllTo <ApptStatusDto>().ToList());
        }