コード例 #1
0
        public void AddReading()
        {
            try
            {
                //  MonthYear = ReadingTakenDate.AddMonths(-1);
                //  var reading = _readingService.GetReadingOfTenant(this.TenantId,MonthYear);
                //  if (reading != null)
                //     throw new InvalidOperationException("Tenant Already Exist");

                //_readingService.AddNewReading(new Reading
                //{
                //    TenantId=this.TenantId,
                //    MonthYear=this.ReadingTakenDate.AddMonths(-1),
                //    PreviousReading = this.PreviousReading,
                //    PresentReading = this.PresentReading,
                //    ReadingTakenDate = this.ReadingTakenDate,
                //    DayOffset = this.DayOffset

                //});
                _readingService.AddNewReading(ReadingList);
                Notification = new NotificationModel("Success!", "Reading successfuly created", NotificationModel.NotificationType.Success);
            }
            catch (InvalidOperationException ex)
            {
                Notification = new NotificationModel(
                    "Failed !! ",
                    "Please insert atleast one tenant",
                    NotificationModel.NotificationType.Fail);
                _logger.LogError(ex.Message);
            }
            catch (DuplicateReadingException iex)
            {
                Notification = new NotificationModel(
                    "Failed!",
                    "Duplicate reading found in your insertion list",
                    NotificationModel.NotificationType.Fail);
                _logger.LogError(iex.Message);
            }

            catch (Exception ex)
            {
                Notification = new NotificationModel(
                    "Failed!",
                    "Failed to create Reading, please insert previous month bill unit price",
                    NotificationModel.NotificationType.Fail);
                _logger.LogError(ex.Message);
            }
        }