Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,OsType")] OpSystem opSystem)
        {
            if (id != opSystem.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(opSystem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OpSystemExists(opSystem.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(opSystem));
        }
Example #2
0
        public void UpdateItem(OpSystem opSystem)
        {
            int index = opSystems.FindIndex(op => op.OpSystemPK == opSystem.OpSystemPK);

            opSystems[index] = opSystem;
            NotifyDataSetChanged();
        }
Example #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_addEdit);

            typeOfWork = (Fragments.TypeOfWork)Intent.GetIntExtra("TypeOfWork", (int)Fragments.TypeOfWork.Add);

            nameEditText      = FindViewById <EditText>(Resource.Id.nameText);
            companyEditText   = FindViewById <EditText>(Resource.Id.companyText);
            progLangEditText  = FindViewById <EditText>(Resource.Id.progLangText);
            versionEditText   = FindViewById <EditText>(Resource.Id.versionText);
            platformsEditText = FindViewById <EditText>(Resource.Id.platformText);
            marketEditText    = FindViewById <EditText>(Resource.Id.marketText);

            OpSystem temp;

            if ((temp = Intent.GetExtra <OpSystem>("Edit")) != null)
            {
                opSystem               = temp;
                nameEditText.Text      = opSystem.Name;
                companyEditText.Text   = opSystem.CompanyName;
                progLangEditText.Text  = opSystem.ProgrammingLanguage;
                versionEditText.Text   = opSystem.LatestVersion;
                platformsEditText.Text = opSystem.SupportedPlatforms;
                marketEditText.Text    = opSystem.MarketShare.ToString();
            }

            Button btn = FindViewById <Button>(Resource.Id.BtnSubmit);

            btn.Click += BtnSubmit_Click;
        }
Example #4
0
        public static OpSystem GetInstance(string name)
        {
            if (instance == null)
            {
                instance = new OpSystem(name);
            }

            return(instance);
        }
Example #5
0
        public async Task <IActionResult> Create([Bind("Id,OsType")] OpSystem opSystem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(opSystem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(opSystem));
        }
Example #6
0
 public void NotifyCollectionChanged(TypeOfWork typeOfWork, OpSystem opSystem)
 {
     if (typeOfWork == TypeOfWork.Add)
     {
         dataAdapter.AddItem(opSystem);
     }
     else if (typeOfWork == TypeOfWork.Edit)
     {
         dataAdapter.UpdateItem(opSystem);
     }
 }
Example #7
0
 public Classroom(string v1, string v2, int v3, bool v4, bool v5, bool v6, OpSystem both, List <Software> ss)
 {
     id           = v1;
     description  = v2;
     num_of_seats = v3;
     projector    = v4;
     board        = v5;
     smart_board  = v6;
     os           = both;
     software     = ss;
 }
Example #8
0
            public void Bind(OpSystem opSystem, bool isSelected)
            {
                if (isSelected)
                {
                    selectedImageView.Visibility = ViewStates.Visible;
                }
                else
                {
                    selectedImageView.Visibility = ViewStates.Gone;
                }

                nameTextView.Text    = opSystem.Name;
                companyTextView.Text = opSystem.CompanyName;
                versionTextView.Text = opSystem.LatestVersion;
            }
Example #9
0
        private static void Main(string[] args)
        {
            new Thread(() =>
            {
                var comp2 = new Computer();
                comp2.Os  = OpSystem.GetInstance("Windows 10");
                Console.WriteLine(comp2.Os.Name);
            }).Start();

            var comp = new Computer();

            comp.Launch("Windows 8.1");
            Console.WriteLine(comp.Os.Name);

            Console.ReadKey();
        }
 public IActionResult Upsert(OpSystem opSystem)
 {
     if (ModelState.IsValid)
     {
         if (opSystem.Id == 0)
         {
             _unitOfWork.OpSystem.Add(opSystem);
         }
         else
         {
             _unitOfWork.OpSystem.Update(opSystem);
         }
         _unitOfWork.Save();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(opSystem));
 }
        public IActionResult Upsert(int?id)
        {
            OpSystem opSystem = new OpSystem();

            if (id == null)
            {
                //this is for create
                return(View(opSystem));
            }
            //this is for edit
            opSystem = _unitOfWork.OpSystem.Get(id.GetValueOrDefault());
            if (opSystem == null)
            {
                return(NotFound());
            }
            return(View(opSystem));
        }
Example #12
0
        private async void ToolbarMenu_MenuItemClick(object sender, Toolbar.MenuItemClickEventArgs e)
        {
            Intent intent;

            switch (e.Item.ItemId)
            {
            case Resource.Id.menu_item_add:
                intent = new Intent(Activity, typeof(AddEditActivity));
                intent.PutExtra("TypeOfWork", (int)TypeOfWork.Add);
                StartActivityForResult(intent, 0);
                break;

            case Resource.Id.menu_item_edit:
                intent = new Intent(Activity, typeof(AddEditActivity));
                if (dataAdapter.GetSelected == null)
                {
                    return;
                }
                intent.PutExtra("Edit", JsonConvert.SerializeObject(dataAdapter.GetSelected));
                intent.PutExtra("TypeOfWork", (int)TypeOfWork.Edit);
                StartActivityForResult(intent, 0);
                break;

            case Resource.Id.menu_item_delete:
                using (ApplicationContext context = new ApplicationContext())
                {
                    OpSystem deleted = dataAdapter.GetSelected;
                    if (deleted == null)
                    {
                        return;
                    }
                    context.OperatingSystems.Remove(deleted);
                    await context.SaveChangesAsync();
                }
                dataAdapter.RemoveItem(dataAdapter.SelectedId);
                break;

            default:
                break;
            }
        }
Example #13
0
 public void Launch(string osName)
 {
     Os = OpSystem.GetInstance(osName);
 }
Example #14
0
 public void AddItem(OpSystem opSystem)
 {
     opSystems.Add(opSystem);
     NotifyDataSetChanged();
 }