public ActionResult Index(FM_Vehicle modelBind) { if (ModelState.IsValid) { string Picture = null; FM_Vehicle modelResult = new FM_Vehicle(); Picture = UploadImg("/Content/Images/Vehicles/Original/", "v-" + modelBind.ChassisNumber.Replace(" ", "_"), 150, 150); string Thumb = (!string.IsNullOrEmpty(Picture)) ? UploadImg("/Content/Images/Vehicles/Thumb/", "v-" + modelBind.ChassisNumber.Replace(" ", "_"), 32, 32) : null; if (!string.IsNullOrEmpty(Picture)) { // ud.Manage("UpdatePicture", Id.ToString(), Picture);xyz.Replace(" ", string.empty); modelResult = model.Insert_Vehicle("Insert_Vehicle_With_Image", modelBind.TypeId, modelBind.ManuId, modelBind.ModelId, modelBind.SubModelId, modelBind.Year, modelBind.ChassisNumber, modelBind.RegistrationNumber, true, Picture.Replace(" ", "_"), modelBind.VehicleGroupId, modelBind.IMEIId); } else { modelResult = model.Insert_Vehicle("Insert_Vehicle", modelBind.TypeId, modelBind.ManuId, modelBind.ModelId, modelBind.SubModelId, modelBind.Year, modelBind.ChassisNumber, modelBind.RegistrationNumber, true, modelBind.VehicleGroupId, modelBind.IMEIId); } ViewBag.VehicleEntry = "True"; TempData["EditResp"] = "CreatedSuccessfully"; /* == Insert Notification When Create New Vehicle Start == */ AL_SetNotification DumyObject = new AL_SetNotification(); DumyObject.AlertConfigId = 7; DumyObject.EntityId = modelResult.VehicleId; DumyObject.Notification = "Vehicle \"" + modelBind.RegistrationNumber + "\" Created."; DumyObject.AlertRecieverId = 11; DumyObject.UserId = 29; DumyObject.IsPushAlertSent = 0; DumyObject.IsPushAlertRead = 0; DumyObject.IsEmailAlertSent = 0; AlertModel.SendNotification("InsertNotification", DumyObject); /* == Insert Notification When Create New Vehicle End == */ return(RedirectToAction("Edit", new { id = modelResult.VehicleId })); } else { ViewBag.VehicleEntry = "False"; ViewBag.VehicleGroupId = modelBind.VehicleGroupId; ViewBag.ManuId = modelBind.ManuId; ViewBag.TypeId = modelBind.TypeId; ViewBag.ModelId = modelBind.ModelId; ViewBag.SubModelId = modelBind.SubModelId; ViewBag.IMEI = modelBind.IMEI; } return(View(modelBind)); }
public void SendNotification(FM_Tracker_Alarms modelBind, string Vreg, int VID, int AssignTo) { /* == Insert Notification When Create New Vehicle Start == */ AL_SetNotification DumyObject = new AL_SetNotification(); AL_GetNotification UserNotify = new AL_GetNotification(); AL_AlertBL AlertModel = new AL_AlertBL(); string AlarmDescriptions = GetDescription(modelBind.AlrmCodes); WebConfig wc = new WebConfig(); string UserIDForNotication = wc.AppSettings("NotificationUserID"); DumyObject.AlertConfigId = 1005; DumyObject.EntityId = VID; DumyObject.Notification = "Car:" + Vreg + " generates " + AlarmDescriptions + " Alarm, current value: " + modelBind.CurrentVal; DumyObject.AlertRecieverId = 29; //11; //AssignTo; DumyObject.UserId = Convert.ToInt32(UserIDForNotication); //12;//(int)ViewBag.UserId; DumyObject.IsPushAlertSent = 1; DumyObject.IsPushAlertRead = 0; DumyObject.IsEmailAlertSent = 0; //sendEmail(); NotificationHub SRNotificationHub = new NotificationHub(); AL_Notification ReadNotification = new AL_Notification(); ReadNotification.SentTo = "11"; /* == Send Alerts based on Users == */ List <AL_GetNotification> ModelResultReceiver = AlertModel.SendNotification("InsertNotification", DumyObject); for (var x = 0; x < ModelResultReceiver.Count; x++) { UserNotify.AlertRecieverId = ModelResultReceiver[x].AlertRecieverId; List <AL_GetNotification> ModelResult = AlertModel.GetNotification("NotificationBell", UserNotify); var json = JsonConvert.SerializeObject(ModelResult); SRNotificationHub.SendNotification(ModelResultReceiver[x].AlertRecieverId.ToString(), json); } /* == Insert Notification When Create New Vehicle End == */ }