コード例 #1
0
ファイル: PmsSummaryService.cs プロジェクト: yhsantosa/Pear
        public CreatePmsSummaryResponse CreatePmsSummary(CreatePmsSummaryRequest request)
        {
            var response = new CreatePmsSummaryResponse();
            try
            {
                var pmsSummary = request.MapTo<PmsSummary>();
                DataContext.PmsSummaries.Add(pmsSummary);
                DataContext.SaveChanges();
                response.Message = "Configuration has been added successfully";
                response.IsSuccess = true;
            }
            catch (DbUpdateException dbUpdateException)
            {
                response.Message = dbUpdateException.Message;
            }

            return response;
        }
コード例 #2
0
ファイル: PmsSummaryService.cs プロジェクト: fazar/Pear
        public CreatePmsSummaryResponse CreatePmsSummary(CreatePmsSummaryRequest request)
        {
            var response = new CreatePmsSummaryResponse();
            try
            {
                var pmsSummary = request.MapTo<PmsSummary>();
                var isExisted = DataContext.PmsSummaries.FirstOrDefault(x => x.IsActive);
                if (request.IsActive && isExisted != null)
                {
                    response.Message = string.Format(@"There is one Pms Summary has actived already, You have to unactivate first.");
                    return response;
                }
                DataContext.PmsSummaries.Add(pmsSummary);
                DataContext.SaveChanges();
                response.Message = "Configuration has been added successfully";
                response.IsSuccess = true;
            }
            catch (DbUpdateException dbUpdateException)
            {
                response.Message = dbUpdateException.Message;
            }

            return response;
        }