public IActionResult GetTotalUnit(string month, int year) { Month enumMonth = (Month)Enum.Parse(typeof(Month), month); var data = _readingService.GetTotalUnitLocal(new DateTime(year, (int)enumMonth, 1)); return(Json(data)); }
public void AddBills() { try { if (this.TotalUnitLocal == 0) { this.TotalUnitLocal = _readingService.GetTotalUnitLocal(new DateTime(this.Year, (int)Month, 1)); } var bill = _billService.GetBillOfThisMonth(this.Month, this.Year); if (bill != null) { throw new NullReferenceException("Bill Already Exists"); } _billService.AddNewBill(new Bill { DescoBillOfThisMonth = this.DescoBillOfThisMonth, Month = this.Month, Year = this.Year, TotalUnitLocal = this.TotalUnitLocal, UnitPriceForNextMonth = this.DescoBillOfThisMonth / this.TotalUnitLocal }); Notification = new NotificationModel("Success !", "Bill Added Successfully", NotificationModel.NotificationType.Success); } catch (NullReferenceException ex) { Notification = new NotificationModel("Failed !!", "Already Exists Bill of this Month. ", NotificationModel.NotificationType.Fail); _logger.LogError(ex.Message); } catch (Exception ex) { Notification = new NotificationModel("Failed !!", "Failed to Insert Bill", NotificationModel.NotificationType.Fail); _logger.LogError(ex.Message); } }