Beispiel #1
0
 public IHttpActionResult CreateDuplexBatch([FromUri] int duplexId, [FromBody] DuplexBatchModel model)
 {
     if (ModelState.IsValid)
     {
         var duplexBatch = new DuplexBatch(model.RunId, model.Position);
         Mapper.Map(model, duplexBatch);
         if (!_duplexesService.IsDuplexBatchExists(duplexBatch))
         {
             _duplexesService.CreateDuplexBatch(duplexBatch);
             model.Id = duplexBatch.Id;
         }
         else
         {
             model.SetError("DuplexBatchNumber", "Duplicate strand batch");
         }
     }
     else
     {
         foreach (var message in ModelState)
         {
             model.SetError(message.Key, message.ToString());
         }
     }
     return(Ok(model));
 }
Beispiel #2
0
        public IHttpActionResult GetDuplexBatch([FromUri] int duplexBatchId)
        {
            var duplexBatch = _duplexesService.GetDuplexBatch(duplexBatchId);
            var model       = new DuplexBatchModel();

            Mapper.Map(duplexBatch, model);
            return(Ok(model));
        }
Beispiel #3
0
 public IHttpActionResult Update([FromUri] int duplexId, [FromUri] int duplexBatchId, [FromBody] DuplexBatchModel model)
 {
     if (ModelState.IsValid)
     {
         var duplexBatch = _duplexesService.GetDuplexBatch(duplexBatchId);
         if (duplexBatch != null)
         {
             duplexBatch.DuplexBatchStrandBatches.Clear();
             Mapper.Map(model, duplexBatch);
             duplexBatch.DuplexBatchNumber = string.Format("{0}_{1}", duplexBatch.RunId, duplexBatch.Position);
             if (!_duplexesService.IsDuplexBatchExists(duplexBatch))
             {
                 _duplexesService.UpdateDuplexBatch(duplexBatch);
                 model.Id = duplexBatch.Id;
             }
             else
             {
                 model.SetError("DuplexBatchNumber", "Duplicate strand batch");
             }
         }
     }
     else
     {
         foreach (var message in ModelState)
         {
             model.SetError(message.Key, message.ToString());
         }
     }
     return(Ok(model));
 }