Note that there are some explanatory texts on larger screens.

plurals
  1. POCan possible to use strategy Pattern to apply with save log for application
    primarykey
    data
    text
    <p>My question is I wanna apply strategy pattern to save log</p> <p><img src="https://i.stack.imgur.com/g2nO2.gif" alt="enter image description here"></p> <p>from Image above</p> <p>I will use replace my class to image</p> <p>Context = Log Class Istrategy = ILog</p> <p>concreteStrategyA = CreateSituation</p> <p>concreteStrategyB = NameSituation</p> <p>concreteStrategyC = StatusSituation</p> <p>[Additional from image]</p> <p>concreteStrategyD = PriceSituation</p> <p>concreteStrategyE = DiscountSituation</p> <p>In ILog have these method SaveLog(Log log);</p> <p>each concreteStrategyA,B,C,D,E implement ILog</p> <p>public class CreateSituation : ILog</p> <p>{</p> <pre><code>public void SaveLog(Log log) { using(var context = new ProductContext()) { log.Message = "This product is created"; context.productLog.InsertonSubmit(log); context.submitChange(); } } </code></pre> <p>}</p> <p>public class NameSituation : ILog</p> <p>{</p> <pre><code>public void SaveLog(Log log) { using(var context = new ProductContext()) { log.Message = "this produce has updated name from \"oldProduct\" to \"newProduct\""; context.productLog.InsertonSubmit(log); context.submitChange(); } } </code></pre> <p>}</p> <p>public class StatusSituation : ILog</p> <p>{</p> <pre><code>public void SaveLog(Log log) { using(var context = new ProductContext()) { log.Message = "this produce has updated status from \"In stock\" to \"Sold Out\""; context.productLog.InsertonSubmit(log); context.submitChange(); } } </code></pre> <p>}</p> <p>public class PriceSituation : ILog</p> <p>{</p> <pre><code>public void SaveLog(Log log) { using(var context = new ProductContext()) { log.Message = "this produce has updated price from $10 to $150"; context.productLog.InsertonSubmit(log); context.submitChange(); } } </code></pre> <p>}</p> <p>public class DiscountSituation : Ilog</p> <p>{</p> <pre><code>public void SaveLog(Log log) { using(var context = new ProductContext()) { log.Message = "this product has updated discount price from $0 to $20"; context.productLog.InsertonSubmit(log); context.submitChange(); } } </code></pre> <p>}</p> <p>In the future can have more than present situation</p> <p>and these classes that I show i a good way to solve these problem</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload