コード例 #1
0
        public void SendNotificationsToUsers(int CustomerId, string Heading, string Message, string ImageUrl, string IsWithImage, int count)
        {
            string Flag = "15";

            //send notification
            // var Customers = _CustomerService.GetCustomers().Where(c => c.CustomerId != CustomerId && c.IsActive == true).ToList();
            CommonClass CommonClass = new Services.CommonClass();
            string      QStr        = "";
            DataTable   dt          = new DataTable();

            QStr = "Select * From Customer where CustomerId = " + CustomerId + " and IsActive=1";
            dt   = CommonClass.GetDataSet(QStr).Tables[0];
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    var ApplicationId = dr["ApplicationId"].ToString();
                    var DeviceType    = dr["DeviceType"].ToString();
                    //var IsNotificationSoundOn = Convert.ToBoolean(dr["IsNotificationSoundOn"]);
                    var    IsNotificationSoundOn = true;
                    string sql = "insert into [notification](RequestMessage,NotificationSendTo,NotificationSendBy,Flag,IsRead) values(@RequestMessage,@NotificationSendTo,@NotificationSendBy,@Flag,@IsRead)";
                    try
                    {
                        string constring = ConfigurationManager.ConnectionStrings["DataContext"].ConnectionString;
                        using (SqlConnection con = new SqlConnection(constring))
                        {
                            using (SqlCommand cmd = new SqlCommand(sql, con))
                            {
                                cmd.CommandType = CommandType.Text;
                                cmd.Parameters.AddWithValue("@RequestMessage", Message);
                                cmd.Parameters.AddWithValue("@NotificationSendTo", dr["CustomerId"].ToString());
                                cmd.Parameters.AddWithValue("@NotificationSendBy", CustomerId);
                                cmd.Parameters.AddWithValue("@Flag", Flag);
                                cmd.Parameters.AddWithValue("@IsRead", false);
                                con.Open();
                                int rowsAffected = cmd.ExecuteNonQuery();
                                cmd.Dispose();
                                con.Close();
                                con.Dispose();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    if (ApplicationId != null && ApplicationId != "")
                    {
                        bool NotificationStatus = true;

                        string JsonMessage = "{\"Flag\":\"" + Flag + "\",\"Message\":\"" + Message + "\",\"Heading\":\"" + Heading + "\",\"ImageUrl\":\"" + ImageUrl + "\",\"IsWithImage\":\"" + IsWithImage + "\"}";
                        if (DeviceType == EnumValue.GetEnumDescription(EnumValue.DeviceType.Android))
                        {
                            CommonCls.SendGCM_Notifications(ApplicationId, JsonMessage, true);
                        }
                        else
                        {
                            string constring = ConfigurationManager.ConnectionStrings["DataContext"].ConnectionString;

                            using (SqlConnection con = new SqlConnection(constring))
                            {
                                con.Open();
                                using (SqlCommand thisCommand = new SqlCommand("SELECT COUNT(*) FROM Notification where NotificationSendTo=@NotificationSendTo and isread=0 ", con))
                                {
                                    thisCommand.Parameters.AddWithValue("@NotificationSendTo", Convert.ToInt32(dr["CustomerId"].ToString()));
                                    count = (int)(thisCommand.ExecuteScalar());
                                }

                                con.Close();
                                con.Dispose();
                            }
                            //Dictionary<string, object> Dictionary = new Dictionary<string, object>();
                            //Dictionary.Add("Flag", Flag);
                            //Dictionary.Add("Message", Message);
                            //NotificationStatus = PushNotificatinAlert.SendPushNotification(ApplicationId, Message, Flag.ToString(), JsonMessage, Dictionary, 1, Convert.ToBoolean(IsNotificationSoundOn));
                            CommonCls.TestSendFCM_Notifications(ApplicationId, JsonMessage, Message, count, true);
                        }
                    }
                }
            }
        }
コード例 #2
0
        public ActionResult Create(EventModel EventModel, HttpPostedFileBase file)
        {
            UserPermissionAction("event", RoleAction.view.ToString());
            CheckPermission();
            TempData["ShowMessage"] = "";
            TempData["MessageBody"] = "";
            try
            {
                if (ModelState.IsValid)
                {
                    if (string.IsNullOrEmpty(EventModel.EventDate.ToString()))
                    {
                        TempData["ShowMessage"] = "error";
                        TempData["MessageBody"] = "Please select a valid Event Date.";
                        return(View("Create", EventModel));
                    }

                    if (string.IsNullOrEmpty(EventModel.EventName))
                    {
                        TempData["ShowMessage"] = "error";
                        TempData["MessageBody"] = "Please Fill Event Name.";
                        return(View("Create", EventModel));
                    }

                    if (string.IsNullOrEmpty(EventModel.EventDescription))
                    {
                        TempData["ShowMessage"] = "error";
                        TempData["MessageBody"] = "Please Fill  EventDescription.";
                        return(View("Create", EventModel));
                    }
                    //CultureInfo culture = new CultureInfo("en-US");
                    //DateTime TodayDate = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy"), culture);
                    //if (Convert.ToDateTime(EventModel.EventDate.ToString("MM/dd/yyyy"), culture) < TodayDate)
                    //{

                    //    TempData["ShowMessage"] = "error";
                    //    TempData["MessageBody"] = "You cannot add old date event.";
                    //    return View("Create", EventModel);
                    //}

                    Mapper.CreateMap <CommunicationApp.Models.EventModel, CommunicationApp.Entity.Event>();
                    CommunicationApp.Entity.Event Event = Mapper.Map <CommunicationApp.Models.EventModel, CommunicationApp.Entity.Event>(EventModel);
                    string EventImage = "";
                    if (file != null)
                    {
                        if (Event.EventImage != "")
                        {   //Delete Old Image
                            string pathDel = Server.MapPath("~/EventPhoto");

                            FileInfo objfile = new FileInfo(pathDel);
                            if (objfile.Exists) //check file exsit or not
                            {
                                objfile.Delete();
                            }
                            //End :Delete Old Image
                        }

                        //Save the photo in Folder
                        var    fileExt  = Path.GetExtension(file.FileName);
                        string fileName = Guid.NewGuid() + fileExt;
                        var    subPath  = Server.MapPath("~/EventPhoto");

                        //Check SubPath Exist or Not
                        if (!Directory.Exists(subPath))
                        {
                            Directory.CreateDirectory(subPath);
                        }
                        //End : Check SubPath Exist or Not

                        var path = Path.Combine(subPath, fileName);
                        file.SaveAs(path);

                        EventImage = CommonCls.GetURL() + "/EventPhoto/" + fileName;
                    }

                    Event.CustomerId = Convert.ToInt32(Session["CustomerId"]);//CutomerId
                    Event.IsActive   = true;
                    Event.CreatedOn  = DateTime.Now;
                    Event.EventImage = EventImage;
                    _EventService.InsertEvent(Event);
                    List <int> CustomerIds = new List <int>();
                    var        Customers   = new List <Customer>();
                    try
                    {
                        if (EventModel.All == true)
                        {
                            EventModel.SelectedCustomer = null;
                            Customers = _CustomerService.GetCustomers().ToList();
                            foreach (var Customer in Customers)
                            {
                                CustomerIds.Add(Convert.ToInt32(Customer.CustomerId));
                                EventCustomer EventCustomer = new Entity.EventCustomer();
                                EventCustomer.EventId    = Event.EventId;
                                EventCustomer.CustomerId = Customer.CustomerId;
                                _EventCustomerService.InsertEventCustomer(EventCustomer);
                            }
                        }
                        else if (EventModel.SelectedCustomer != null)
                        {
                            foreach (var Customer in EventModel.SelectedCustomer)
                            {
                                CustomerIds.Add(Convert.ToInt32(Customer));
                                EventCustomer EventCustomer = new Entity.EventCustomer();
                                EventCustomer.EventId    = Event.EventId;
                                EventCustomer.CustomerId = Event.CustomerId;
                                _EventCustomerService.InsertEventCustomer(EventCustomer);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ErrorLogging.LogError(ex);
                        throw;
                    }



                    string Flag    = "12";//status for Event;
                    var    Message = "New event saved.";
                    //send notification
                    try
                    {
                        var CustomerList = _CustomerService.GetCustomers().Where(c => CustomerIds.Contains(c.CustomerId) && c.CustomerId != EventModel.CustomerId && c.IsActive == true).ToList();
                        foreach (var Customer in CustomerList)
                        {
                            if (Customer != null)
                            {
                                if (Customer.ApplicationId != null && Customer.ApplicationId != "")
                                {
                                    bool NotificationStatus = true;

                                    string JsonMessage = "{\"Flag\":\"" + Flag + "\",\"Message\":\"" + Message + "\"}";
                                    try
                                    {
                                        //Save Notification
                                        Notification Notification = new Notification();
                                        Notification.NotificationSendBy = 1;
                                        Notification.NotificationSendTo = Convert.ToInt32(Customer.CustomerId);
                                        Notification.IsRead             = false;
                                        Notification.Flag           = Convert.ToInt32(Flag);
                                        Notification.RequestMessage = Message;
                                        _Notification.InsertNotification(Notification);
                                        if (Customer.DeviceType == EnumValue.GetEnumDescription(EnumValue.DeviceType.Android))
                                        {
                                            CommonCls.SendGCM_Notifications(Customer.ApplicationId, JsonMessage, true);
                                        }
                                        else
                                        {
                                            int count = _Notification.GetNotifications().Where(c => c.NotificationSendTo == Convert.ToInt32(Customer.CustomerId) && c.IsRead == false).ToList().Count();
                                            //Dictionary<string, object> Dictionary = new Dictionary<string, object>();
                                            //Dictionary.Add("Flag", Flag);
                                            //Dictionary.Add("Message", Message);
                                            //NotificationStatus = PushNotificatinAlert.SendPushNotification(Customer.ApplicationId, Message, Flag, JsonMessage, Dictionary, 1, Convert.ToBoolean(Customer.IsNotificationSoundOn));
                                            CommonCls.TestSendFCM_Notifications(Customer.ApplicationId, JsonMessage, Message, count, true);
                                            ////Save Notification
                                            //Notification Notification = new Notification();
                                            //Notification.NotificationSendBy = 1;
                                            //Notification.NotificationSendTo = Customer.CustomerId;
                                            //Notification.IsRead = false;
                                            //Notification.RequestMessage = Message;
                                            //_Notification.InsertNotification(Notification);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        CommonCls.ErrorLog(ex.ToString());
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ErrorLogging.LogError(ex);
                        throw;
                    }

                    TempData["ShowMessage"] = "success";
                    TempData["MessageBody"] = "Event successfully saved.";
                    return(RedirectToAction("Index"));
                }
                var errors           = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();
                var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors);
                var CustomerList1    = _CustomerService.GetCustomers();
                EventModel.CustomersList = CustomerList1.Select(x => new SelectListItem {
                    Value = x.CustomerId.ToString(), Text = x.FirstName
                }).ToList();
                EventModel.CustomerId = 1;
                return(View(EventModel));
            }
            catch (Exception ex)
            {
                ErrorLogging.LogError(ex);

                return(View(EventModel));
            }
        }
コード例 #3
0
        public ActionResult Edit([Bind(Include = "CustomerId,TrebId,WebsiteUrl,ApplicationID,Password,CompanyID,UserId,PhotoPath,FirstName,LastName,MiddleName,EmailID,DOB,MobileNo,CountryID,StateID,CityID,ZipCode,Latitude,Longitude,CreatedOn,LastUpdatedOn,MobileVerifyCode,EmailVerifyCode,IsMobileVerified,IsEmailVerified,IsActive,RecoNumber,RecoExpireDate")] CustomerModel Customermodel, HttpPostedFileBase file)
        {
            UserPermissionAction("property", RoleAction.view.ToString());
            CheckPermission();
            TempData["ShowMessage"] = "";
            TempData["MessageBody"] = "";
            try
            {
                TempData["ShowMessage"] = "error";
                TempData["MessageBody"] = "Please fill the required field with valid data";
                if (ModelState.IsValid)
                {
                    var CustomerFound = _CustomerService.GetCustomers().Where(c => ((c.EmailId.Trim() == Customermodel.EmailID.Trim() || c.MobileNo.Trim() == Customermodel.MobileNo.Trim()) && c.CustomerId != Customermodel.CustomerId)).FirstOrDefault();
                    if (CustomerFound == null)
                    {
                        var PhotoPath = "";

                        var CustomerUpdate = _CustomerService.GetCustomer(Customermodel.CustomerId);//.Where(c => c.CustomerId == Customermodel.CustomerId).FirstOrDefault();
                        if (CustomerUpdate != null)
                        {
                            PhotoPath = CustomerUpdate.PhotoPath;
                            if (file != null)
                            {
                                if (CustomerUpdate.PhotoPath != "")
                                {   //Delete Old Image
                                    string pathDel = Server.MapPath("~/CustomerPhoto");

                                    FileInfo objfile = new FileInfo(pathDel);
                                    if (objfile.Exists) //check file exsit or not
                                    {
                                        objfile.Delete();
                                    }
                                    //End :Delete Old Image
                                }

                                //Save the photo in Folder
                                var    fileExt  = Path.GetExtension(file.FileName);
                                string fileName = Guid.NewGuid() + fileExt;
                                var    subPath  = Server.MapPath("~/CustomerPhoto");

                                //Check SubPath Exist or Not
                                if (!Directory.Exists(subPath))
                                {
                                    Directory.CreateDirectory(subPath);
                                }
                                //End : Check SubPath Exist or Not

                                var path = Path.Combine(subPath, fileName);
                                file.SaveAs(path);

                                PhotoPath = CommonCls.GetURL() + "/CustomerPhoto/" + fileName;
                            }


                            CommonClass CommonClass = new CommonClass();
                            string      QStr        = "";
                            DataTable   dt          = new DataTable();
                            QStr  = "update Customer set PhotoPath='" + PhotoPath + "' ,MobileNo='" + Customermodel.MobileNo + "' ,Address='" + Customermodel.Address + "' ,FirstName='" + Customermodel.FirstName + "' ";
                            QStr += " ,LastName='" + Customermodel.LastName + "',MiddleName='" + Customermodel.MiddleName + "' ,EmailId='" + Customermodel.EmailID + "' ,CityID='" + Convert.ToInt32(Customermodel.CityID) + "' ,StateID='" + Convert.ToInt32(Customermodel.StateID) + "' , ";
                            QStr += "IsActive='" + Convert.ToBoolean(Customermodel.IsActive) + "' ,WebsiteUrl='" + Customermodel.WebsiteUrl + "' ,UpdateStatus='" + true + "' Where CustomerId='" + Convert.ToInt32(Customermodel.CustomerId) + "'  ";
                            CommonClass.ExecuteNonQuery(QStr);
                            // dt = CommonClass.GetDataSet(QStr).Tables[0];
                            CustomerUpdate.LastUpdatedOn = DateTime.Now;
                            _CustomerService.UpdateCustomer(CustomerUpdate);
                            if (Customermodel.IsActive == false)
                            {
                                string Flag = "14";
                                var    NotificationStatus = false;
                                string Message            = "Your account is deactivated";
                                string JsonMessage        = "{\"Flag\":\"" + Flag + "\",\"Message\":\"" + Message + "\"}";
                                //Save Notification
                                Notification Notification = new Notification();
                                Notification.NotificationSendBy = 1;
                                Notification.NotificationSendTo = Convert.ToInt32(CustomerUpdate.CustomerId);
                                Notification.IsRead             = false;
                                Notification.Flag           = Convert.ToInt32(Flag);
                                Notification.RequestMessage = Message;
                                _Notification.InsertNotification(Notification);
                                if (CustomerUpdate.DeviceType == EnumValue.GetEnumDescription(EnumValue.DeviceType.Android))
                                {
                                    CommonCls.SendGCM_Notifications(CustomerUpdate.ApplicationId, JsonMessage, true);
                                }
                                else
                                {
                                    //Dictionary<string, object> Dictionary = new Dictionary<string, object>();
                                    //Dictionary.Add("Flag", Flag);
                                    //Dictionary.Add("Message", Message);
                                    //NotificationStatus = PushNotificatinAlert.SendPushNotification(CustomerUpdate.ApplicationId, Message, Flag.ToString(), JsonMessage, Dictionary, 1);
                                    int count = _Notification.GetNotifications().Where(c => c.NotificationSendTo == Convert.ToInt32(CustomerUpdate.CustomerId) && c.IsRead == false).ToList().Count();

                                    CommonCls.TestSendFCM_Notifications(CustomerUpdate.ApplicationId, JsonMessage, Message, count, true);
                                }
                            }
                            string FirstName = CustomerUpdate.FirstName + " " + CustomerUpdate.MiddleName + " " + CustomerUpdate.LastName;
                            if (CustomerUpdate.IsUpdated == true)
                            {
                                SendMailToUpdatedUser(FirstName, CustomerUpdate.EmailId, CustomerUpdate.TrebId);
                            }
                            else
                            {
                                SendMailToUser(FirstName, CustomerUpdate.EmailId, CustomerUpdate.TrebId);
                            }



                            TempData["ShowMessage"] = "success";
                            TempData["MessageBody"] = CustomerUpdate.FirstName + " is update successfully.";
                        }
                        else
                        {
                            TempData["ShowMessage"] = "error";
                            TempData["MessageBody"] = "Customer not found.";
                        }
                        return(RedirectToAction("customerlist", "Property"));
                    }
                    else
                    {
                        TempData["ShowMessage"] = "error";

                        if (CustomerFound.EmailId.Trim() == Customermodel.EmailID.Trim())
                        {
                            TempData["MessageBody"] = Customermodel.EmailID + " is already exists.";
                        }
                        if (CustomerFound.TrebId.Trim() == Customermodel.TrebId.Trim())
                        {
                            TempData["MessageBody"] = Customermodel.TrebId + " is already exists.";
                        }
                        if (CustomerFound.MobileNo.Trim() == Customermodel.MobileNo.Trim())
                        {
                            TempData["MessageBody"] = "This" + " " + Customermodel.MobileNo + " is already exists.";
                        }
                        else
                        {
                            TempData["MessageBody"] = "Please fill the required field with valid data";
                        }
                    }
                }
            }


            catch (RetryLimitExceededException)
            {
                TempData["ShowMessage"] = "error";
                TempData["MessageBody"] = "Some unknown problem occured while proccessing save operation on " + Customermodel.FirstName + " client";
            }
            var errors           = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();
            var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors);

            //ViewBag.CityID = new SelectList(_CityService.GetCities(), "CityID", "CityName", Carriermodel.CityID);
            // ViewBag.CompanyID = new SelectList(_CompanyService.GetCompanies(), "CompanyID", "CompanyName", Customermodel.CompanyID);
            //ViewBag.CountryID = new SelectList(_CountryService.GetCountries(), "CountryID", "CountryName", Carriermodel.CountryID);
            //ViewBag.StateID = new SelectList(_StateService.GetStates(), "StateID", "StateName", Carriermodel.StateID);
            ViewBag.UserId      = new SelectList(_UserService.GetUsers(), "UserId", "FirstName", Customermodel.UserId);
            ViewBag.CityID      = (Customermodel.CityID <= 0 ? "" : Customermodel.CityID.ToString());
            ViewBag.StateID     = (Customermodel.StateID <= 0 ? "" : Customermodel.StateID.ToString());
            ViewBag.Countrylist = new SelectList(_CountryService.GetCountries(), "CountryID", "CountryName", Customermodel.CountryID);
            ViewBag.Statelist   = new SelectList(_StateService.GetStates(), "StateID", "StateName", Customermodel.StateID);
            ViewBag.Citylist    = new SelectList(_CityService.GetCities(), "CityID", "CityName", Customermodel.CityID);


            return(View(Customermodel));
        }
コード例 #4
0
        public HttpResponseMessage SaveComment([FromBody] CommentModel CommentModel)
        {
            var    taskAssignedToIds = new List <NotifyModel>();
            string UserMessage       = "";
            string NotificationType  = "";
            string setFlag           = "";

            try
            {
                if (CommentModel.TaskId == 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Task Id is blank."), Configuration.Formatters.JsonFormatter));
                }
                if (CommentModel.CustomerId == 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Customer Id is blank."), Configuration.Formatters.JsonFormatter));
                }
                if (CommentModel.CommentMessage == null && CommentModel.CommentMessage == "")
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Comment Message is blank."), Configuration.Formatters.JsonFormatter));
                }

                Mapper.CreateMap <Onlo.Models.CommentModel, Onlo.Entity.Comment>();
                Onlo.Entity.Comment Comment = Mapper.Map <Onlo.Models.CommentModel, Onlo.Entity.Comment>(CommentModel);
                Comment.CustomerId     = CommentModel.CustomerId;
                Comment.CommentMessage = CommentModel.CommentMessage;
                Comment.TaskId         = CommentModel.TaskId;
                _CommentService.InsertComment(Comment);

                var Task     = _TasksService.GetTask(CommentModel.TaskId);
                var customer = _CustomerService.GetCustomer(CommentModel.CustomerId);
                Onlo.Entity.Customer CustomerBy = _CustomerService.GetCustomer(Convert.ToInt32(CommentModel.CustomerId));

                if (CustomerBy.CustomerType == EnumValue.GetEnumDescription(EnumValue.CustomerType.Teacher))
                {
                    var taskAssignedToStudent = _TaskCustomerService.GetTaskCustomers().Where(t => t.TaskID == CommentModel.TaskId).ToList();
                    var ids = taskAssignedToStudent.Select(t => t.CustomerId).ToList();

                    foreach (var item in ids)
                    {
                        NotifyModel notify = new NotifyModel();
                        notify.AssignId = item;

                        taskAssignedToIds.Add(notify);
                    }

                    foreach (var item in ids)
                    {
                        NotifyModel notifyy = new NotifyModel();
                        var         taskAssignedToParent = _CustomerService.GetCustomers().Where(c => c.ParentId == item).FirstOrDefault();
                        if (taskAssignedToParent != null)
                        {
                            notifyy.AssignId = taskAssignedToParent.CustomerId;

                            taskAssignedToIds.Add(notifyy);
                        }
                    }
                    if (Task.TaskType == EnumValue.GetEnumDescription(EnumValue.DietType.Diet))
                    {
                        UserMessage      = "You have new comment on diet - " + Task.TaskName + ".";
                        NotificationType = "Teacher_CommentDiet";
                        setFlag          = "Teacher_DietComment";
                    }
                    else
                    {
                        UserMessage      = "You have new comment on task - " + Task.TaskName + ".";
                        NotificationType = "Teacher_CommentTask";
                        setFlag          = "Teacher_TaskComment";
                    }
                }
                else if (CustomerBy.CustomerType == EnumValue.GetEnumDescription(EnumValue.CustomerType.Student))
                {
                    NotifyModel notify = new NotifyModel();
                    var         taskAssignedToParent1 = _CustomerService.GetCustomers().Where(c => c.ParentId == CommentModel.CustomerId).FirstOrDefault();
                    if (taskAssignedToParent1 != null)
                    {
                        notify.AssignId = taskAssignedToParent1.CustomerId;
                        taskAssignedToIds.Add(notify);
                    }

                    NotifyModel notifyy = new NotifyModel();
                    var         taskAssignedToTeacher1 = _CustomerService.GetCustomers().Where(c => c.CustomerId == customer.ParentId).FirstOrDefault();
                    notifyy.AssignId = taskAssignedToTeacher1.CustomerId;
                    taskAssignedToIds.Add(notifyy);
                    if (Task.TaskType == EnumValue.GetEnumDescription(EnumValue.DietType.Diet))
                    {
                        UserMessage      = "You have new comment on diet - " + Task.TaskName + ".";
                        NotificationType = "Student_CommentDiet";
                        setFlag          = "Student_DietComment";
                    }
                    else
                    {
                        UserMessage      = "You have new comment on task - " + Task.TaskName + ".";
                        NotificationType = "Student_CommentTask";
                        setFlag          = "Student_TaskComment";
                    }
                }
                else if (CustomerBy.CustomerType == EnumValue.GetEnumDescription(EnumValue.CustomerType.Parent))
                {
                    NotifyModel notify = new NotifyModel();
                    var         taskAssignedToStudent2 = _CustomerService.GetCustomers().Where(c => c.CustomerId == customer.ParentId).FirstOrDefault();
                    notify.AssignId = taskAssignedToStudent2.CustomerId;
                    taskAssignedToIds.Add(notify);
                    NotifyModel notifyy = new NotifyModel();
                    var         taskAssignedToTeacher = _CustomerService.GetCustomers().Where(c => c.CustomerId == taskAssignedToStudent2.ParentId).FirstOrDefault();
                    if (taskAssignedToTeacher != null)
                    {
                        notifyy.AssignId = taskAssignedToTeacher.CustomerId;

                        taskAssignedToIds.Add(notifyy);
                    }
                    if (Task.TaskType == EnumValue.GetEnumDescription(EnumValue.DietType.Diet))
                    {
                        UserMessage      = "You have new comment on diet - " + Task.TaskName + ".";
                        NotificationType = "Parent_CommentDiet";
                        setFlag          = "Parent_DietComment";
                    }
                    else
                    {
                        UserMessage      = "You have new comment on task - " + Task.TaskName + ".";
                        NotificationType = "Parent_CommentTask";
                        setFlag          = "Parent_TaskComment";
                    }
                }
                foreach (var taskAssignedToId in taskAssignedToIds)
                {
                    string ApplicationId = _CustomerService.GetCustomerApplicationIds(Convert.ToInt32(taskAssignedToId.AssignId), EnumValue.GetEnumDescription(EnumValue.DeviceType.Android)) + ",";

                    if (ApplicationId != null && ApplicationId != "'',")
                    {
                        Notification Notification = new Notification();

                        Notification.CustomerId       = taskAssignedToId.AssignId;
                        Notification.TaskID           = Task.TaskId;
                        Notification.UserMessage      = UserMessage;
                        Notification.NotificationType = NotificationType;
                        Notification.Flag             = setFlag;
                        Notification.DeviceType       = EnumValue.GetEnumDescription(EnumValue.DeviceType.Android);
                        _NotificationService.InsertNotification(Notification);
                        string Message = "";

                        if (Task.TaskType == EnumValue.GetEnumDescription(EnumValue.DietType.Diet))
                        {
                            Message = "{\"flag\":\"" + setFlag + "\",\"TaskId\":\"" + Task.TaskId + "\",\"DietName\":\"" + Task.TaskName + "\",\"CommentMsg\":\"" + CommentModel.CommentMessage + "\",\"Name\":\"" + CustomerBy.Name + "\",\"PhotoPath\":\"" + CustomerBy.PhotoPath + "\",\"Id\":\"" + CustomerBy.CustomerId + "\"}";
                        }
                        else
                        {
                            Message = "{\"flag\":\"" + setFlag + "\",\"TaskId\":\"" + Task.TaskId + "\",\"CommentMsg\":\"" + CommentModel.CommentMessage + "\",\"DietName\":\"" + Task.TaskName + "\",\"Name\":\"" + CustomerBy.Name + "\",\"PhotoPath\":\"" + CustomerBy.PhotoPath + "\",\"Id\":\"" + CustomerBy.CustomerId + "\"}";
                        }

                        CommonCls.SendGCM_Notifications(ApplicationId, Message, true);
                    }
                }

                return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("success", "Comment added successfully."), Configuration.Formatters.JsonFormatter));
            }
            catch (Exception ex)
            {
                string ErrorMsg = ex.Message.ToString();
                ErrorLogging.LogError(ex);
                return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Please try later."), Configuration.Formatters.JsonFormatter));
            }
        }