public static WebResult <bool> Reset() { try { ImageEntity.RemoveAll(); GroomEntity.RemoveAll(); return(new WebResult <bool>() { Status = true, Message = "Ok", Value = true }); } catch (Exception e) { return(new WebResult <bool>() { Status = false, Message = e.Message, Value = false }); } }
public static WebResult <List <ImageEntity> > InsertGroom(List <String> base64arr) { List <ImageEntity> images = null; try { images = Images.GetImages().Value; if (base64arr.Count == 2) { var base64 = Regex.Replace(base64arr[0], @"^data:image\/[a-zA-Z]+;base64,", string.Empty); byte[] byteArray = System.Convert.FromBase64String(base64); MemoryStream stream = new MemoryStream(byteArray); string urlStorage = InitImages.SendToStorage(base64arr[1], stream); if (urlStorage == "") { return new WebResult <List <ImageEntity> >() { Status = false, Message = "failed to load image", Value = images } } ; GroomEntity groom = new GroomEntity(); groom.url = urlStorage; string token = getFaceToken(urlStorage); if (token == "") { return new WebResult <List <ImageEntity> >() { Status = false, Message = "failed", Value = images } } ; groom.token = token; groom.name = base64arr[1]; if (GroomEntity.Get().ToList().Count > 0) { GroomEntity.RemoveAll(); groom.Add(); InitImagesAfterChangeGroom(); images = Images.GetImages().Value; return(new WebResult <List <ImageEntity> >() { Status = true, Message = "Ok", Value = images }); } groom.Add(); return(new WebResult <List <ImageEntity> >() { Status = true, Message = "Ok", Value = Images.GetImages().Value }); } return(new WebResult <List <ImageEntity> >() { Status = false, Message = "That's not an image", Value = images }); } catch (Exception e) { return(new WebResult <List <ImageEntity> >() { Status = false, Message = e.Message, Value = images }); } }