コード例 #1
0
        public MetaTabControlViewModel(IContainerExtension container, IRegionManager regionManager)
        {
            _regionManager = regionManager;
            _modelMaster   = container.Resolve <ModelMaster>();

            _modelMaster.ObserveProperty(x => x.ImageMetas).Where(x => x != null).Subscribe(x => AddTab(x));
        }
コード例 #2
0
        public async Task <IHttpActionResult> PutModelMaster(int id, ModelMaster modelMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != modelMaster.Id)
            {
                return(BadRequest());
            }

            db.Entry(modelMaster).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ModelMasterExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public MainWindowViewModel(IContainerExtension container, IRegionManager regionManager)
        {
            _regionManager = regionManager;
            _modelMaster   = container.Resolve <ModelMaster>();

            AddTab1Command       = new DelegateCommand(AddTab1);
            AddTab2Command       = new DelegateCommand(AddTab2);
            ClearAllMarksCommand = new DelegateCommand(ClearAllMarks);
        }
コード例 #4
0
        public async Task <IHttpActionResult> GetModelMaster(int id)
        {
            ModelMaster modelMaster = await db.ModelMasters.FindAsync(id);

            if (modelMaster == null)
            {
                return(NotFound());
            }

            return(Ok(modelMaster));
        }
コード例 #5
0
        public async Task <IHttpActionResult> PostModelMaster(ModelMaster modelMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ModelMasters.Add(modelMaster);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = modelMaster.Id }, modelMaster));
        }
コード例 #6
0
        public async Task <IHttpActionResult> DeleteModelMaster(int id)
        {
            ModelMaster modelMaster = await db.ModelMasters.FindAsync(id);

            if (modelMaster == null)
            {
                return(NotFound());
            }

            db.ModelMasters.Remove(modelMaster);
            await db.SaveChangesAsync();

            return(Ok(modelMaster));
        }
コード例 #7
0
        public async Task <ActionResult> Create(ModelsListModel model, bool continueEditing)
        {
            try
            {
                var modelInfo = new ModelMaster
                {
                    ModelCode    = model.ModelCode,
                    ModelName    = model.ModelName,
                    FriendlyName = model.FriendlyName,
                    Active       = model.Active,
                    Deleted      = false,
                    DateUpdated  = DateTime.UtcNow,
                    DateCreated  = DateTime.UtcNow,
                    ByUser       = Convert.ToInt32(HttpContext.User.FindFirst(claim => claim.Type == System.Security.Claims.ClaimTypes.NameIdentifier)?.Value)
                };

                await _modelMasterService.InsertAsync(modelInfo);

                //add model varient mapping
                foreach (var varMap in model.SelectedVarientIds)
                {
                    await _modelMasterService.AddVarientMappingAsync(new ModelVarientMapping
                    {
                        ModelId   = modelInfo.Id,
                        VarientId = varMap
                    });
                }

                if (continueEditing)
                {
                    return(RedirectToAction(nameof(Edit), new { id = modelInfo.Id }));
                }

                TempData["UserMessageSuccess"] = "Record saved sucessfully.";
                return(RedirectToAction(nameof(List)));
            }
            catch (Exception ex)
            {
                TempData["UserMessageError"] = ex.Message.ToString();
                return(RedirectToAction(nameof(Create)));
            }
        }
コード例 #8
0
 public async Task DeleteAsync(ModelMaster entity)
 {
     await _modelMasterRepo.RemoveAsync(entity);
 }
コード例 #9
0
 public async Task UpdateAsync(ModelMaster entity)
 {
     await _modelMasterRepo.UpdateAsync(entity);
 }
コード例 #10
0
 public async Task InsertAsync(ModelMaster entity)
 {
     await _modelMasterRepo.AddAsync(entity);
 }