I'm pretty new to MVC
, it's my first project and I'm trying to learn best practices. I'm using Entity Framework
.
Here is the thing:
I have two models, one is for overtime work records and other one for accounting records.
When I create an overtime work record, I want to create an accounting record too. So lets say I created overtime record with 2 hours of work, I want to create an accounting record with value of "hours of work (2) * employees overtime work salary".
I can easily do this in OvertimeController's create method but I'm not sure if I should access other models (Accounting Model) from that controller.
What's the best way to do it?
Here is my models, i'm using code first:
Accounting
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int AccountingId { get; set; }
public decimal AccountingType { get; set; }
public decimal AccountingMethod { get; set; }
public string AccountingNote { get; set; }
public decimal AccountingBorc { get; set; }
public decimal AccountingAlacak { get; set; }
public decimal WorkerId { get; set; }
public decimal PhaseId { get; set; }
public virtual Worker Worker { get; set; }
public virtual Phase Phase { get; set; }
Overhours
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int OverhourId { get; set; }
public int WorkerId { get; set; }
public int PhaseId { get; set; }
public int OverhourAmount { get; set; }
public DateTime OverhourDate { get; set; }
public virtual Worker Worker { get; set; }
public virtual Phase Phase { get; set; }
Thanks