Exemplo n.º 1
0
        private void btnAddTemplate_Click(object sender, System.EventArgs e)
        {
            var     microwave = Wrap(() => _service.GetMicroWave());
            Int16   timeleft  = microwave.TimeLeft;
            Potency potency   = microwave.Potency;

            if (microwave.CurrentJob != null)
            {
                timeleft = microwave.CurrentJob.Template.TimeLeft;
                potency  = microwave.CurrentJob.Template.Potency;
            }

            var newJobTemplate = new JobTemplate(timeleft, potency)
            {
                CanDelete    = true,
                Default      = false,
                Instructions = txtOutput.Text,
                Name         = txtSearchTemplate.Text,
                MealKind     = GetSelectedMealKind(),
                Dot          = txtSearchTemplate.Text[0]
            };

            var ds = Wrap(() => _service.SaveTemplate(newJobTemplate));

            if (ds != null)
            {
                txtSearchTemplate.Text = String.Empty;
                lbxTemplate.DataSource = ds;
            }
        }
Exemplo n.º 2
0
 public void OverridePotency(Potency potency)
 {
     this.Potency = Potency;
     if (this.CurrentJob != null)
     {
         this.CurrentJob.OverridePotency(potency);
     }
 }
Exemplo n.º 3
0
 public DigitalMicroWave(IList <JobTemplate> templates, Int16 defaultTime, Potency defaultPotency)
 {
     this.Status        = MicroWaveStatus.JobLess;
     this.CurrentJob    = null;
     this._templateList = templates;
     this.Potency       = defaultPotency;
     this.TimeLeft      = defaultTime;
 }
Exemplo n.º 4
0
        // GET: Potencies/Delete/5
        public ActionResult DeletePotency(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Potency potency = db.Potencies.Find(id);

            if (potency == null)
            {
                return(HttpNotFound());
            }

            return(View(potency));
        }
Exemplo n.º 5
0
        public ActionResult AddPotency([Bind(Include = "Potency_Id,Potency_mg")] Potency potency)
        {
            Potency persuser = db.Potencies.FirstOrDefault(u => u.Potency_mg == (potency.Potency_mg));

            if (persuser == null)
            {
                db.Potencies.Add(potency);
                db.SaveChanges();
                return(RedirectToAction("ListPotencies"));
            }
            else
            {
                ModelState.AddModelError("Potency_mg", "Potency Can not be added as it already exists.");
            }
            return(View());
        }
Exemplo n.º 6
0
        public ActionResult DeletePotencyConfirmed(int id)
        {
            Potency         potency = db.Potencies.Find(id);
            MedicinePotency meddd   = db.MedicinePotencies.FirstOrDefault(u => u.Potency_Id == potency.Potency_Id);

            if (meddd != null)
            {
                ModelState.AddModelError("Potency_mg", "This Potency can not be Deleted Because some medicines has this potency.");
                return(View());
            }

            else
            {
                db.Potencies.Remove(potency);
                db.SaveChanges();
                return(RedirectToAction("ListPotencies"));
            }
        }
Exemplo n.º 7
0
 public void OverridePotency(Potency potency)
 {
     this.Potency = Potency;
 }
Exemplo n.º 8
0
 public JobTemplate(Int16 timeLeft, Potency potency)
 {
     this.Id       = Guid.NewGuid();
     this.TimeLeft = timeLeft;
     this.Potency  = potency;
 }
Exemplo n.º 9
0
 /// <summary>
 /// To be called only by JobTemplateParameterLess
 /// </summary>
 public JobTemplate(Int16 timeLeft, Potency potency, Guid id)
 {
     this.Id       = id;
     this.TimeLeft = timeLeft;
     this.Potency  = potency;
 }