Exemple #1
0
        public static bool UpdateItem(SampleDataModel data)
        {
            bool result = false;

            if (data != null)
            {
                var updateObject = sampleData.FirstOrDefault(x => x.Id == data.Id);
                if (updateObject != null)
                {
                    updateObject.Title       = data.Title;
                    updateObject.Description = data.Description;
                    result = true;
                }
            }

            return(result);
        }
Exemple #2
0
        public static SampleDataModel CreateItem(SampleDataModel data)
        {
            // Figure out a new ID of course
            var lastIdentifier = sampleData.OrderBy(x => x.Id).LastOrDefault();

            if (lastIdentifier == null)
            {
                data.Id = 1;
            }
            else
            {
                data.Id = lastIdentifier.Id + 1;
            }

            sampleData.Add(data);

            return(data);
        }