public async Task <IActionResult> ReadNotification([FromBody] ReadNotifRequest request)
        {
            //Check if required fields are present
            if (!ModelState.IsValid)
            {
                return(Ok(new ReadNotifResponse {
                    success = 0
                }));
            }

            //Convert response object to DTO Objects
            var serialized_req = Newtonsoft.Json.JsonConvert.SerializeObject(request);
            var converted_req  = Newtonsoft.Json.JsonConvert.DeserializeObject <DTO.Request.ReadNotifRequest>(serialized_req);

            //await result from function ChangePassword
            var result = await Task.FromResult(_loginManagement.ReadNotification(converted_req));

            return(Ok(new ReadNotifResponse {
                success = result.success
            }));
        }
Example #2
0
        /*
         * Method to set notification to read
         *
         */

        public ReadNotifResponse ReadNotification(ReadNotifRequest readNotifRequest)
        {
            if (!readNotifRequest.id_number.Equals(String.Empty))
            {
                var notif = _ucOnlinePortalContext._212notifications.Where(x => x.StudId == readNotifRequest.id_number).ToList();

                if (notif != null)
                {
                    notif.ForEach(x => x.NotifRead = 1);
                }
            }
            else
            {
                var notif = _ucOnlinePortalContext._212notifications.Where(x => x.NotifId == readNotifRequest.notif_id).FirstOrDefault();
                notif.NotifRead = 1;
            }

            _ucOnlinePortalContext.SaveChanges();

            return(new ReadNotifResponse {
                success = 1
            });
        }