Exemple #1
0
        /// <summary>新增番茄資料</summary>
        /// <returns></returns>
        public string AddTomato(TomatoViewModel models)
        {
            models.TomatoID = Guid.NewGuid().ToString();
            models.CreateTime = DateTime.Now;
            models.IsCompleted = false;

            Mapper.CreateMap<TomatoViewModel, Tomato>()
                    .ForMember(x => x.SpentTime, y => y.Ignore())
                    .ForMember(x => x.FinishTime, y => y.Ignore());
            var Tomato = Mapper.Map<TomatoViewModel, Tomato>(models);
            db.Insert(Tomato);

            return models.TomatoID;
        }
Exemple #2
0
 public HttpResponseMessage StartTomato(TomatoViewModel models)
 {
     try
     {
         string tomatoID = service.AddTomato(models);
         return Request.CreateResponse(HttpStatusCode.OK, tomatoID);
     }
     catch (Exception ex)
     {
        return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message.ToString());
     }
 }
Exemple #3
0
        /// <summary>番茄暫停</summary>
        /// <param name="models"></param>
        public void PauseTomato(TomatoViewModel models)
        {
            var tomato = db.GetByID(models.TomatoID);
            tomato.PauseCount = tomato.PauseCount + 1;

            db.Update(tomato);
        }
Exemple #4
0
 public HttpResponseMessage PauseTomato(TomatoViewModel models)
 {
     try
     {
         service.PauseTomato(models);
         return Request.CreateResponse(HttpStatusCode.OK);
     }
     catch (Exception ex)
     {
         return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message.ToString());
     }
 }