private async Task GetCemeteryAsync(SupervisorModel model) { if (CrossConnectivity.Current.IsConnected) { var cem = await _apiCemetery.GetCemeteryAsync(model.CemeteryId); if (cem.status == "Success") { //will be used for cemetry location var objDevice = new CemeteryGeolocationModel { CemeteryName = cem.objDevice.CemeteryLocation.CemeteryName, Latitude = cem.objDevice.CemeteryLocation.Latitude, Longitude = cem.objDevice.CemeteryLocation.Longitude, }; Password = string.Empty; Username = string.Empty; await Application.Current.MainPage.Navigation.PushAsync(new Burials(model, _apiBurial)); } } else { Device.BeginInvokeOnMainThread(() => { Application.Current.MainPage.DisplayAlert("Error Network Connection", "You need to be connected to the internet and restart the application if possible", "OK"); IsBusy = false; }); } }
public async Task <IHttpActionResult> Put([FromBody] SupervisorModel model) { IdentityUser user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); // Se obtiene el supervisor y se actualiza la fecha de modificación y el estatus var supervisor = supervisorService.GetSingle(c => c.SV_ID_SUPERVISOR == model.SV_ID_SUPERVISOR); if (supervisor != null) { supervisor.SV_FECHA_MOD = DateTime.Now.Date; supervisor.SV_ESTATUS = Convert.ToInt16(RegistryStateModel.RegistryState.Pendiente); supervisor.SV_FECHA_MOD = DateTime.Now.Date; supervisor.SV_ID_AREA = model.SV_ID_AREA; supervisor.CE_ID_EMPRESA = model.CE_ID_EMPRESA; supervisor.SV_ID_SUPERVISOR = model.SV_ID_SUPERVISOR; supervisor.SV_LIMITE_MINIMO = model.SV_LIMITE_MINIMO; supervisor.SV_LIMITE_SUPERIOR = model.SV_LIMITE_SUPERIOR; //supervisorService.Update(supervisor); // Se obtiene el supervisor temporal para luego actualizarlo con el supervisor var supervisorTemp = supervisorTempService.GetSingle(c => c.SV_ID_SUPERVISOR == model.SV_ID_SUPERVISOR); supervisorTemp = MappingTempFromSupervisor(supervisorTemp, supervisor); supervisorTemp.SV_ESTATUS = Convert.ToInt16(RegistryStateModel.RegistryState.PorAprobar); supervisorTempService.Update(supervisorTemp); return(Ok()); } else { return(NotFound()); } }
public void ProcessDiscoveryWithNoResultsAndNoExistingApplications() { var found = new List <DiscoveryEventModel>(); var fix = new Fixture(); var device = fix.Create <string>(); var module = fix.Create <string>(); var super = SupervisorModelEx.CreateSupervisorId(device, module); var deviceModel = new DeviceModel { Id = device, ModuleId = module }; var twinModel = new SupervisorModel { Id = super }.ToSupervisorRegistration().ToDeviceTwin(); var registry = IoTHubServices.Create((twinModel, deviceModel).YieldReturn()); using (var mock = AutoMock.GetLoose()) { // Setup mock.Provide <IIoTHubTwinServices>(registry); mock.Provide <ISupervisorRegistry, SupervisorRegistry>(); mock.Provide <IApplicationBulkProcessor, ApplicationRegistry>(); mock.Provide <IEndpointBulkProcessor, EndpointRegistry>(); var service = mock.Create <DiscoveryProcessor>(); // Run service.ProcessDiscoveryResultsAsync(super, new DiscoveryResultModel(), found).Wait(); // Assert Assert.Empty(registry.Devices); } }
public async Task <IHttpActionResult> PutAprobarParametro([FromBody] AprobacionModel model) { IdentityUser user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); var tempModel = supervisorTempService.GetSingle(c => c.SV_ID_SUPERVISOR == model.id); int estadoAprobado = Convert.ToInt32(RegistryStateModel.RegistryState.Aprobado); var listSupervisor = supervisorService.GetAll(c => c.CE_ID_EMPRESA == tempModel.CE_ID_EMPRESA && c.SV_ID_AREA == tempModel.SV_ID_AREA && c.SV_ESTATUS == estadoAprobado && c.SV_COD_SUPERVISOR == tempModel.SV_COD_SUPERVISOR, null, includes: c => c.SAX_EMPRESA); if (listSupervisor != null & listSupervisor.Count > 0) { return(BadRequest("Supervisor duplicado, por favor rechazar.")); } if (tempModel != null) { tempModel.SV_FECHA_APROBACION = DateTime.Now.Date; tempModel.SV_ESTATUS = Convert.ToInt16(RegistryStateModel.RegistryState.Aprobado); tempModel.SV_USUARIO_APROBADOR = user.Id; supervisorTempService.Update(tempModel); SupervisorModel supervisor = new SupervisorModel(); supervisor = MappingSupervisorFromTemp(supervisor, tempModel); supervisorService.Update(supervisor); return(Ok("El supervisor ha sido aprobado.")); } return(BadRequest("No se encontraron datos para actualizar.")); }
public BurialsViewModel(SupervisorModel model, IBurialService apiBurial) { if (CrossConnectivity.Current.IsConnected) { _apiBurial = apiBurial; _supervisor = model; SupervisorId = model.SupervisorId; _burialList = new List <BurialModel>(); _refreshCommand = new Command(async() => await RefreshList(model)); _sqLiteConnection = DependencyService.Get <ISQLite>().GetConnection(); _sqLiteConnection.CreateTable <Burial>(); _onTapGestureRecognizerTapped = new Command(OnTapped); OutputAgeCommand = new Command <BurialModel>(OutputAge); Reload(); } else { Device.BeginInvokeOnMainThread(() => { Application.Current.MainPage.DisplayAlert("Error Network Connection", "You need to be connected to the internet and restart the application", "OK"); IsBusy = false; }); } }
public Burials(SupervisorModel model, IBurialService apiBurial) { InitializeComponent(); this._model = model; _apiBurial = apiBurial; lblFullname.Text = model.Fullname; BindingContext = _burialViewModel = new BurialsViewModel(model, apiBurial); }
public async Task <bool> DeleteSupervisorAsync(SupervisorModel model) { var supervisor = _mapper.Map <Supervisor>(model); _parkRepository.Delete(supervisor); return(await _parkRepository.SaveChangesAsync()); }
private void tbSupervisor_Click(object sender, EventArgs e) { SupervisorModel model = UnityContainer.Resolve <SupervisorModel>(); BaseView baseView = model.CreateForm(); baseView.MdiParent = this; baseView.WindowState = FormWindowState.Maximized; baseView.Show(); }
private async Task LoginAsync(SigninModel model) { await Task.Run(async() => { try { StartEnabled = false; ButtonText = "Signing-in..."; IsBusy = true; var results = await _apiServices.LoginAsync(model.Username, model.Password); if (results.status == "Success" && results.objSupervisor != null) { var objSupervisor = new SupervisorModel() { CemeteryId = results.objSupervisor.CemeteryId, Name = results.objSupervisor.Name, Surname = results.objSupervisor.Surname, SupervisorId = results.objSupervisor.SupervisorId, UserName = results.objSupervisor.UserName, SupervisorPassword = results.objSupervisor.SupervisorPassword }; _objSupervisor = objSupervisor; } else { Device.BeginInvokeOnMainThread(() => { Application.Current.MainPage.DisplayAlert("Error login", "Username/Password invalid", "OK"); IsBusy = false; StartEnabled = true; ButtonText = "Sign-in"; }); _objSupervisor = null; } } catch (Exception ex) { Device.BeginInvokeOnMainThread(() => { Application.Current.MainPage.DisplayAlert("Error Message", ex.Message, "OK"); }); } finally { IsBusy = false; StartEnabled = true; ButtonText = "Sign-in"; } }); }
/// <summary> /// Create supervisor event /// </summary> /// <param name="type"></param> /// <param name="context"></param> /// <param name="supervisorId"></param> /// <param name="supervisor"></param> /// <returns></returns> private static SupervisorEventModel Wrap(SupervisorEventType type, RegistryOperationContextModel context, string supervisorId, SupervisorModel supervisor) { return(new SupervisorEventModel { EventType = type, Context = context, Id = supervisorId, Supervisor = supervisor }); }
/// <summary> /// Create from service model /// </summary> /// <param name="model"></param> public SupervisorApiModel(SupervisorModel model) { Id = model.Id; SiteId = model.SiteId; Discovery = model.Discovery; LogLevel = model.LogLevel; DiscoveryConfig = model.DiscoveryConfig == null ? null : new DiscoveryConfigApiModel(model.DiscoveryConfig); Certificate = model.Certificate; OutOfSync = model.OutOfSync; Connected = model.Connected; }
private async Task <List <BurialModel> > PopulateList(SupervisorModel model) { Device.BeginInvokeOnMainThread(() => IsBusy = true); var items = await _apiBurial.GetBurialAsync(model.CemeteryId); if (items.objBurial.Count > 0) { await AddDataLocaly(items.objBurial.ToList()); } Device.BeginInvokeOnMainThread(() => IsBusy = false); return(items.objBurial.ToList()); }
public async Task <SupervisorModel> AddNewSupervisorAsync(SupervisorModel model) { var supervisor = _mapper.Map <Supervisor>(model); _parkRepository.Add(supervisor); if (await _parkRepository.SaveChangesAsync()) { return(_mapper.Map <SupervisorModel>(supervisor)); } return(null); }
public DataTable selectbyUserid(SupervisorModel objSupervisorModel) { try { return(Execution.ExecuteParamerizedSelectCommand("sp_employee", new SqlParameter[] { new SqlParameter("@Command", "SELECTBYUSERIDFORSP"), new SqlParameter("@userId", objSupervisorModel.userid), })); } catch (Exception ex) { throw ex; } }
public CoreProjectModel ScaffoldModel(OpenApiOptions options) { SupervisorModel supervisorModel = Supervisor.ScaffoldModel(options); SupervisorInterfaceModel supervisorInterfaceModel = SupervisorInterface.ScaffoldModel(options); return(new CoreProjectModel { ProjectFile = CreateProjectFile(options), Supervisor = supervisorModel.File, SupervisorInterface = supervisorInterfaceModel.File, Converters = Converter.ScaffoldModel(options).Files, Entities = Entities.ScaffoldModel(options).Files, ViewModels = ViewModels.ScaffoldModel(options).Files, RepositoryInterfaces = Repositories.ScaffoldModel(options).Files }); }
/// <summary> /// Create api model /// </summary> /// <param name="model"></param> /// <returns></returns> public static SupervisorApiModel ToApiModel( this SupervisorModel model) { if (model == null) { return(null); } return(new SupervisorApiModel { Id = model.Id, SiteId = model.SiteId, LogLevel = (IIoT.OpcUa.Api.Registry.Models.TraceLogLevel?)model.LogLevel, Certificate = model.Certificate, OutOfSync = model.OutOfSync, Connected = model.Connected }); }
public IHttpActionResult Post(SupervisorModel supervisor) { using (var context = new Entities()) { context.Supporter .Add(new Supporter() { Id = supervisor.Id, Name = supervisor.Name, password = supervisor.password, FirstSurname = supervisor.FirstSurname, Email = supervisor.Email }); context.SaveChanges(); } return(Ok()); }
private SupervisorModel MappingSupervisorFromTemp(SupervisorModel supervisor, SupervisorTempModel supervisorTemp) { supervisor.SV_ID_SUPERVISOR = supervisorTemp.SV_ID_SUPERVISOR; supervisor.SV_ID_AREA = supervisorTemp.SV_ID_AREA; supervisor.CE_ID_EMPRESA = supervisorTemp.CE_ID_EMPRESA; supervisor.SV_COD_SUPERVISOR = supervisorTemp.SV_COD_SUPERVISOR; supervisor.SV_LIMITE_MINIMO = supervisorTemp.SV_LIMITE_MINIMO; supervisor.SV_LIMITE_SUPERIOR = supervisorTemp.SV_LIMITE_SUPERIOR; supervisor.SV_ESTATUS = supervisorTemp.SV_ESTATUS; supervisor.SV_FECHA_CREACION = supervisorTemp.SV_FECHA_CREACION; supervisor.SV_USUARIO_CREACION = supervisorTemp.SV_USUARIO_CREACION; supervisor.SV_FECHA_MOD = supervisorTemp.SV_FECHA_MOD; supervisor.SV_USUARIO_MOD = supervisorTemp.SV_USUARIO_MOD; supervisor.SV_FECHA_APROBACION = supervisorTemp.SV_FECHA_APROBACION; supervisor.SV_USUARIO_APROBADOR = supervisorTemp.SV_USUARIO_APROBADOR; return(supervisor); }
public async Task <SupervisorModel> UpdateSupervisorAsync(SupervisorModel model) { var existing = await _parkRepository.GetSupervisorByIdAsync(model.EmployeeId); if (existing == null) { return(null); } _mapper.Map(model, existing); if (await _parkRepository.SaveChangesAsync()) { return(_mapper.Map <SupervisorModel>(existing)); } return(null); }
public async Task <DBResult> Login(AuthenticationModel model) { SupervisorModel result = null; bool hasError = false; string errorText = ""; try { if (ModelState.IsValid || model != null) { result = await Authentication.AuthenticateUser(model.Username, model.Password); if (result == null) { return(new DBResult { status = !hasError ? "Success" : "Fail", descripText = "Username/Password is not valid", data = null }); } } else { hasError = true; } } catch (Exception e) { hasError = true; return(new DBResult { status = !hasError ? "Success" : "Fail", descripText = e.Message.ToString(), data = null }); } return(new DBResult { status = !hasError ? "Success" : "Fail", descripText = errorText, data = new SupervisorModel { SupervisorId = result.SupervisorId, Name = result.Name, Surname = result.Surname, CemeteryId = result.CemeteryId, UserName = result.UserName, SupervisorPassword = result.SupervisorPassword } }); }
public int updateProfile(SupervisorModel objSupervisorModel) { try { return(Execution.ExecuteNonQuery_with_result("sp_employee", new SqlParameter[] { new SqlParameter("@Command", "SUPERVISORPROFILE"), new SqlParameter("@mobile", objSupervisorModel.mobile), new SqlParameter("@email", objSupervisorModel.email), new SqlParameter("@emergencycontact", objSupervisorModel.emergencyContact), new SqlParameter("@profilePic", objSupervisorModel.profilePic), new SqlParameter("@userId", objSupervisorModel.userid), })); } catch (Exception ex) { throw ex; } }
public UndertakerViewModel(BurialModelOutPut burialOutPut, IBurialService apiBurial) { _burialOutPut = burialOutPut; _sqLiteConnection = DependencyService.Get <ISQLite>().GetConnection(); _sqLiteConnection.CreateTable <Burial>(); if (_burialOutPut.BurialApplication != 0) { _burialApplication = _burialOutPut.BurialApplication; _supervisor = new SupervisorModel { CemeteryId = burialOutPut.CemeteryId, SupervisorId = burialOutPut.SupervisorId, Name = burialOutPut.Name, Surname = burialOutPut.Surname }; } _apiBurial = apiBurial; }
public SupervisorModel ScaffoldModel(OpenApiOptions options) { string supervisorNamespace = Dependencies.Namespace.Supervisor(options.RootNamespace); var model = new SupervisorModel(); var classFile = new ScaffoldedFile { //var interfaceFile = new ScaffoldedFile(); Code = Generator.WriteClassCode(options.Document, options.SupervisorClassName, options.SupervisorInterfaceName, supervisorNamespace), Path = Dependencies.PathHelper.Supervisor(options.CoreProjectDir, options.SupervisorClassName) }; //interfaceFile.Code = Generator.WriteInterfaceCode(options.Document, options.SupervisorInterfaceName, supervisorNamespace); //interfaceFile.Path = Dependencies.PathHelper.Supervisor(options.CoreProjectDir, options.SupervisorInterfaceName); model.File = classFile; //model.Interface = interfaceFile; return(model); }
public async Task <IHttpActionResult> Post([FromBody] SupervisorModel model) { IdentityUser user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); model.SV_USUARIO_CREACION = user.Id; model.SV_FECHA_CREACION = DateTime.Now.Date; int estadoAprobado = Convert.ToInt32(RegistryStateModel.RegistryState.Aprobado); var listSupervisor = supervisorService.GetAll(c => c.CE_ID_EMPRESA == model.CE_ID_EMPRESA && c.SV_ID_AREA == model.SV_ID_AREA && c.SV_ESTATUS == estadoAprobado && c.SV_COD_SUPERVISOR == model.SV_COD_SUPERVISOR, null, includes: c => c.SAX_EMPRESA); if (listSupervisor != null & listSupervisor.Count > 0) { return(BadRequest("No se puede registrar un supervisor dos veces en la misma empresa y área.")); } var supervisor = supervisorService.InsertSupervisor(model); return(Ok(supervisor)); }
public static async Task <SupervisorModel> AuthenticateUser(string username, string password) { SupervisorModel result = null; var q = DataAccess.Context.CEM_LIST_CEMETERY_SUPERVISOR.Where(row => row.UserName == username && row.SupervisorPassword == password).Select(row => new { Id = row.Id, Name = row.Name, Surname = row.Surname, CemeteryId = row.CemeteryId, UserName = row.UserName, SupervisorPassword = row.SupervisorPassword }); var qUser = q.FirstOrDefault(); var user = qUser; if (user != null) { result = new SupervisorModel { SupervisorId = user.Id, Name = user.Name, Surname = user.Surname, CemeteryId = user.CemeteryId, UserName = user.UserName, SupervisorPassword = user.SupervisorPassword }; } return(result); }
private async Task RefreshList(SupervisorModel model) { IsRefreshing = true; if (CrossConnectivity.Current.IsConnected) { BurialList = await PopulateList(model); IsRefreshing = false; } else { Device.BeginInvokeOnMainThread(() => { Application.Current.MainPage.DisplayAlert("Error Network Connection", "You need to be connected to the internet and restart the application", "OK"); IsBusy = false; }); IsRefreshing = false; } IsRefreshing = false; }
public IHttpActionResult GetById(int id) { SupervisorModel supervisor = null; using (var context = new Entities()) { supervisor = context.Supervisor .Where(supervisorItem => supervisorItem.Id == id) .Select(supporterItem => new SupervisorModel() { Id = supporterItem.Id, Name = supporterItem.Name, password = supporterItem.password, FirstSurname = supporterItem.FirstSurname, Email = supporterItem.Email }).FirstOrDefault <SupervisorModel>(); } //to do : transform this snippet into a single return if (supervisor == null) { return(NotFound()); } return(Ok(supervisor)); }
/// <inheritdoc/> public Task OnSupervisorUpdatedAsync(RegistryOperationContextModel context, SupervisorModel supervisor) { return(_bus.PublishAsync(Wrap(SupervisorEventType.Updated, context, supervisor.Id, supervisor))); }
public HttpResponseMessage UpdateProfile([FromBody] SupervisorModel objSupervisorModel) { IP = System.Configuration.ConfigurationManager.AppSettings["IP"]; var re = Request; var headers = re.Headers; if (headers.Contains("token")) { token = headers.GetValues("token").First(); } var result = Authtoken.checkToken(token); if (result == true) { if (objSupervisorModel.base64image == null) { string pic = objSupervisorModel.profilePic; objSupervisorModel.profilePic = pic.Replace(IP, ""); objSupervisorDL.updateProfile(objSupervisorModel); dt = objSupervisorDL.selectbyUserid(objSupervisorModel); foreach (DataRow row in dt.Rows) { string url = dt.Rows[0]["profilePic"].ToString(); //need to set value to NewColumn column row["profilePic"] = IP + url; } var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK, new ResponseModel() { message = "Your profile Updated successfully", output = dt, statuscode = Convert.ToInt16(HttpStatusCode.OK) }); return(resp); } else { string baseencode = objSupervisorModel.base64image; // Convert Base64 String to byte[] byte[] imageBytes = Convert.FromBase64String(baseencode); MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length); // Convert byte[] to Image string filename = "/uploads/images/profilepics/" + Authtoken.GeneratePin() + AuthorizationToken.GetTimestamp(DateTime.Now) + ".png"; ms.Write(imageBytes, 0, imageBytes.Length); System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true); image.Save(HttpContext.Current.Server.MapPath(filename), System.Drawing.Imaging.ImageFormat.Png); objSupervisorModel.profilePic = filename; objSupervisorDL.updateProfile(objSupervisorModel); dt = objSupervisorDL.selectbyUserid(objSupervisorModel); foreach (DataRow row in dt.Rows) { string url = dt.Rows[0]["profilePic"].ToString(); //need to set value to NewColumn column row["profilePic"] = IP + url; } var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK, new ResponseModel() { message = "Your profile Updated successfully", output = dt, statuscode = Convert.ToInt16(HttpStatusCode.OK) }); return(resp); } } else { var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK, new ResponseModel() { message = "UnAuthorized", statuscode = Convert.ToInt16(HttpStatusCode.OK), error = true }); return(resp); } }
public void Save(SupervisorModel model) { Dependencies.FileWriter.WriteFile(model.File); //Dependencies.FileWriter.WriteFile(model.Interface); }