// POST: api/Employee
        public string Post([FromBody]RegEmployee RegEmp)
        {
            foreach (var item in EmpMang.GetAllEmployees())
            {
                if (item.EmailID.Equals(RegEmp.EmailID))
                    return "Username already registered";
            }

            Rideally.Entities.Employee emp = new Rideally.Entities.Employee();
            Rideally.Entities.Address home = new Entities.Address();
            Rideally.Entities.Address office = new Entities.Address();
            home.Latitude = RegEmp.HomeLatitude;      home.Longitude = RegEmp.HomeLongitude;       home.type = true;
            office.Latitude = RegEmp.OfficeLatitude;  office.Longitude = RegEmp.OfficeLongitude;   office.type = false;
            emp.HomeAddress = home; emp.OfficeAddress = office;

            Rideally.Entities.Authentication auth = new Entities.Authentication();
            auth.Login = RegEmp.EmailID;
            string password = "******";// System.Web.Security.Membership.GeneratePassword(8, 0);
            auth.Password = Rideally.Util.SaltHash.ComputeHash(password, null, null);
            Rideally.Util.Email.SendMail(RegEmp.EmailID, "RideAlly User Password", "Your password for RideAlly = " + password);
            
            emp.UserAuthentication = auth;
            emp.EmployeeName = RegEmp.EmployeeName;

            emp.Gender = RegEmp.Gender;
            emp.MobileNo = RegEmp.MobileNo;
            emp.EmailID = RegEmp.EmailID;
            return EmpMang.AddEmployee(emp).ToString();
        }
 public bool AddRiderMaster(Entities.RiderMaster RiderMaster)
 {
     bool IsAdded = false;
     if (RiderMaster == null)
         throw new NullReferenceException("Cannot insert Null value");
     Employee emp = new Employee();
     try
     {
         RiderMasterRepo.Create(RiderMaster);
         IsAdded = true;
     }
     catch (Exception)
     {
         throw new RiderMasterNotAddedException("Cannot Add RiderMaster");
     }
     return IsAdded;
 }
 public bool UpdateEmployee(Employee employee)
 {
     bool IsUpdated = false;
     if (employee == null)
         throw new NullReferenceException("Cannot update Null value");
     //Employee emp = new Employee();
     try
     {
         //EmployeeRepo.Detach();
         //EmployeeRepo.Detach(employee.OfficeAddress);
         EmployeeRepo.Update(employee);
         IsUpdated = true;
     }
     catch (Exception ex)
     {
         throw new EmployeeNotAddedException("Cannot update Employee" + ex);
     }
     return IsUpdated;
 }
 public bool AddSchedule(Entities.Schedule schedule)
 {
     bool IsAdded = false;
     if (schedule == null)
         throw new NullReferenceException("Cannot insert Null value");
     Employee emp = new Employee();
     try
     {
         //AddressRepo.Detach(schedule.FromAddress);
         //AddressRepo.Detach(schedule.ToAddress);
         //EmployeeRepo.Detach(schedule.Offerer);
         ScheduleRepo.Create(schedule);
         IsAdded = true;
     }
     catch (Exception ex)
     {
         throw new ScheduleNotAddedException("Cannot Add Schedule"+ex);
     }
     return IsAdded;
 }
         public void InsertSchedule(ScheduleViewModule Sch)
         {
             Schedule schedule = new Schedule();
             Employee emp = new Employee();
             emp =empMan.GetEmployeeByID(Sch.EmployeeId);
             
             schedule.ScheduledDate = Sch.date;
             schedule.ScheduledTime = Sch.starttime;
             schedule.ScheduledStatus = Sch.ScheduleStatus;
             schedule.EmployeeID = Sch.EmployeeId;
             Vehicle veh= vehman.GetVehicleByID(emp.Vehicle.VehicleId);
             schedule.SeatsAvailable = veh.VehicleType.NoOfSeats - 1 ;
             if(Sch.Direction.CompareTo("From_Home")==0)
             {
                 schedule.ToAddressID = emp.OfficeAddress.AddressId;
                 schedule.FromAddressID = emp.HomeAddress.AddressId;
             }
             else
             {
                 schedule.ToAddressID = emp.HomeAddress.AddressId;
                 schedule.FromAddressID = emp.OfficeAddress.AddressId;
             }

             scheduleManager.AddSchedule(schedule);
         }
 public bool DeleteEmployee(Employee employee)
 {
     bool IsDeleted = false;
     if (employee == null)
         throw new NullReferenceException("Cannot delete Null value");
     try
     {
         EmployeeRepo.Delete(employee);
         IsDeleted = true;
     }
     catch (Exception)
     {
         throw new EmployeeNotAddedException("Cannot Delete Employee");
     }
     return IsDeleted;
 }
        public bool AddNotification(Entities.Notification notification)
        {
            bool IsAdded = false;
            if (notification == null)
                throw new NullReferenceException("Cannot insert Null value");
        
          



            Employee emp = new Employee();
            try
            {
                NotificationRepo.Create(notification);
                IsAdded = true;
            }
            catch (Exception)
            {
                throw new NotificationNotAddedException("Cannot Add Notification");
            }
            return IsAdded;
        }