Example #1
0
        public static GroupSchedulingViewModel ToViewModel(this GroupSchedulingModel entity)
        {
            if (entity == null)
            {
                return(null);
            }

            List <GroupSchedulingDetailViewModel> details = new List <GroupSchedulingDetailViewModel>();

            foreach (var grpDetail in entity.GroupDetails)
            {
                var detailModel = new GroupSchedulingDetailViewModel();
                detailModel.GroupCapacity = grpDetail.GroupCapacity;
                detailModel.GroupDetailID = grpDetail.GroupDetailID;
                detailModel.GroupName     = grpDetail.GroupName;
                detailModel.GroupTypeID   = grpDetail.GroupTypeID;
                detailModel.ModifiedOn    = grpDetail.ModifiedOn;
                detailModel.IsActive      = grpDetail.IsActive;
                details.Add(detailModel);
            }

            var model = new GroupSchedulingViewModel()
            {
                GroupHeaderID = entity.GroupHeaderID,
                GroupDetailID = entity.GroupDetailID,
                Comments      = entity.Comments,
                GroupDetails  = details,
                ModifiedOn    = entity.ModifiedOn,
                IsActive      = entity.IsActive
            };

            return(model);
        }
Example #2
0
        public Response <GroupSchedulingModel> AddGroupData(GroupSchedulingModel group)
        {
            var response = new Response <GroupSchedulingModel>()
            {
                ResultCode = -1, ResultMessage = "Error while saving the group's data"
            };

            using (var transactionScope = _unitOfWork.BeginTransactionScope())
            {
                try
                {
                    var                 groupSchedulingRepository = _unitOfWork.GetRepository <GroupSchedulingModel>(SchemaName.Scheduling);
                    var                 groupDetail        = group.GroupDetails[0]; // This is only being used as a signle detail record for now
                    SqlParameter        groupNameParam     = new SqlParameter("GroupName", groupDetail.GroupName);
                    SqlParameter        groupCapacityParam = new SqlParameter("GroupCapacity", groupDetail.GroupCapacity);
                    SqlParameter        groupTypeIDParam   = new SqlParameter("GroupTypeID", groupDetail.GroupTypeID);
                    SqlParameter        modifiedOnParam    = new SqlParameter("ModifiedOn", DateTime.Now.ToUniversalTime());
                    List <SqlParameter> procParams         = new List <SqlParameter>()
                    {
                        groupNameParam, groupCapacityParam, groupTypeIDParam, modifiedOnParam
                    };
                    var detailResult = _unitOfWork.EnsureInTransaction(groupSchedulingRepository.ExecuteNQStoredProc, "usp_AddGroupDetails", procParams,
                                                                       forceRollback: group.ForceRollback.GetValueOrDefault(false), adonResult: false, idResult: true);

                    if (detailResult.ResultCode != 0)
                    {
                        goto end;
                    }

                    group.GroupDetailID = detailResult.ID;
                    var headerResult = AddGroupHeader(group);
                    if (headerResult.ResultCode != 0)
                    {
                        goto end;
                    }

                    detailResult.ID = headerResult.ID;//the group header id will need to be passed back to the UI
                    response        = detailResult;
                    if (!group.ForceRollback.GetValueOrDefault(false))
                    {
                        _unitOfWork.TransactionScopeComplete(transactionScope);
                    }
                }
                catch (Exception ex)
                {
                    _logger.Error(ex);
                    response.ResultCode    = -1;
                    response.ResultMessage = string.Empty;
                }
            }

end:
            return(response);
        }
Example #3
0
        private Response <GroupSchedulingDetailModel> UpdateGroupHeader(GroupSchedulingModel group)
        {
            var                 groupSchedulingRepository = _unitOfWork.GetRepository <GroupSchedulingDetailModel>(SchemaName.Scheduling);
            SqlParameter        groupHeaderIDParam        = new SqlParameter("GroupHeaderID", group.GroupHeaderID);
            SqlParameter        commentsParam             = new SqlParameter("Comments", group.Comments);
            SqlParameter        modifiedOnParam           = new SqlParameter("ModifiedOn", DateTime.Now.ToUniversalTime());
            List <SqlParameter> procParams = new List <SqlParameter>()
            {
                groupHeaderIDParam, commentsParam, modifiedOnParam
            };
            var result = _unitOfWork.EnsureInTransaction(groupSchedulingRepository.ExecuteNQStoredProc, "usp_UpdateGroupSchedulingHeader", procParams,
                                                         forceRollback: group.ForceRollback.GetValueOrDefault(false));

            return(result);
        }
Example #4
0
        public Response <GroupSchedulingModel> UpdateGroupData(GroupSchedulingModel group)
        {
            string apiUrl = BaseRoute + "UpdateGroupData";

            return(_communicationManager.Post <GroupSchedulingModel, Response <GroupSchedulingModel> >(group, apiUrl));
        }
Example #5
0
 public Response <GroupSchedulingModel> UpdateGroupData(GroupSchedulingModel groupID)
 {
     return(_groupSchedulingService.UpdateGroupData(groupID));
 }
Example #6
0
        public IHttpActionResult UpdateGroupData(GroupSchedulingModel group)
        {
            Response <GroupSchedulingModel> responseObject = _groupSchedulingRuleEngine.UpdateGroupData(group);

            return(new HttpResult <Response <GroupSchedulingModel> >(responseObject, Request));
        }
        public IHttpActionResult UpdateGroupData(GroupSchedulingModel group)
        {
            var groupResponse = _groupSchedulingDataProvider.UpdateGroupData(group);

            return(new HttpResult <Response <GroupSchedulingModel> >(groupResponse, Request));
        }