protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            //RequestWindowFeature(WindowFeatures.ActionBar);
            //ActionBar.SetDisplayHomeAsUpEnabled(true);
            //ActionBar.SetHomeButtonEnabled(true);

            int recordId = Intent.GetIntExtra("RecordId", 0);
            if (recordId > 0)
            {
                record = AllOurVinylManager.GetRecord (recordId);
            }
            else
            {
                record = new Record ();
            }

            SetContentView(Resource.Layout.RecordDetails);

            var toolbar = FindViewById<Toolbar> (Resource.Id.toolbar);
            if (toolbar != null) {
                SetActionBar (toolbar);
                ActionBar.SetDisplayHomeAsUpEnabled(true);
                ActionBar.SetHomeButtonEnabled(true);
            }

            titleEditText = FindViewById<EditText>(Resource.Id.txtTitle);
            artistEditText = FindViewById<EditText>(Resource.Id.txtArtist);

            if(titleEditText != null) { titleEditText.Text = record.Title; }
            if(artistEditText != null) { artistEditText.Text = record.Artist; }
        }
Ejemplo n.º 2
0
 public static int SaveRecord(Record item)
 {
     return RecordRepository.SaveRecord (item);
 }
Ejemplo n.º 3
0
        public static int SaveRecord(Record item)
        {
            var existingRecord = Records.FirstOrDefault(x => x.Id == item.Id);
            if (existingRecord != null)
            {
                // update record;
                item.Id = existingRecord.Id;

                Records.Remove(existingRecord);
                Records.Add(item);
            }
            else
            {
                // TODO: remove next id issue (should be resolved when using database / web service)
                var lastRecord = Records.OrderByDescending (x => x.Id).FirstOrDefault ();

                item.Id = 1;
                if (lastRecord != null)
                {
                    item.Id = lastRecord.Id++;
                }

                Records.Add (item);

            }
            return item.Id;
        }