public bool AddTask(OfficerTaskDTO task) { try { if (task == null) { return(false); } var officer = operationalDataContext.Patrols.Where(p => !p.IsPatrol.Value && p.PatrolCode == task.OfficerMilitaryId).FirstOrDefault(); if (officer == null) { return(false); } var pointString = string.Format("POINT({0} {1})", task.Longitude.ToString(), task.Latitude.ToString()); DbGeography dbGeography = DbGeography.FromText(pointString); var officerTask = new OfficerTask { CreateDate = DateTime.Now, GeoLocation = dbGeography, Latitude = task.Latitude, Longitude = task.Longitude, OfficerMilitaryId = task.OfficerMilitaryId, TaskMessage = task.TaskMessage, TaskTime = task.TaskTime, UserId = task.UserId, IsNoticed = false }; officerTask = operationalDataContext.OfficerTask.Add(officerTask); var officertaskstatus = new OfficerTaskStatus { OfficerTaskId = officerTask.OfficerTaskId, StatusUpdateDate = DateTime.Now, TaskStatusId = 1, Latitude = task.Latitude, Longitude = task.Longitude, GeoLocation = dbGeography, IsNoticed = false }; operationalDataContext.OfficerTaskStatus.Add(officertaskstatus); return(operationalDataContext.SaveChanges() > 0); } catch (Exception ex) { return(false); } }
public bool AddTask(OfficerTaskDTO task) { return(new SmartOfficerDAL().AddTask(task)); }