Пример #1
0
        public Message AddToWatchlist(string userid)
        {
            var result = new Message();

            try
            {
                MyDay mday = mydayrep.GetRemovePatient(userid);

                //MyDay mday = mydayrep.GetAll().Where(m => m.PatientId == userid).First();
                WatchList wlist = new WatchList
                {
                    Name      = mday.Name,
                    Subject   = mday.Subject,
                    PatientId = mday.PatientId,
                    UserId    = mday.UserId
                };
                var lastwlistid = repository.GetAll().OrderByDescending(lw => lw.WatchListId).First();
                wlist.WatchListId = Convert.ToInt32(lastwlistid.WatchListId) + 1;

                WatchList wlst = repository.AddToWatchlist(wlist);
                if (wlst != null)
                {
                    result.success = "Success.";
                }
            }
            catch
            {
                result.error = "Error.";
            }
            return(result);
        }