public async Task <IActionResult> PutBusinessCard(int id, BusinessCard businessCard)
        {
            if (id != businessCard.Id)
            {
                return(BadRequest());
            }

            _context.Entry(businessCard).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BusinessCardExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #2
0
        public async Task <ActionResult> EditBusinessCard(UIBusinessCard UserBusinessCard, HttpPostedFileBase uploadImage)
        {
            if (ModelState.IsValid)
            {
                BusinessCard DBUserBusinessCard = await db.BusinessCards.FindAsync(UserBusinessCard.BusinessCardId);

                //конфигурация маппера
                Mapper.Initialize(cfg => cfg.CreateMap <UIBusinessCard, BusinessCard>().ForMember(d => d.Logo, (options) => options.Ignore()));
                //сопоставление
                Mapper.Map(UserBusinessCard, DBUserBusinessCard);
                ApplicationUser user = await GetCurrentUser();

                DBUserBusinessCard.User = user;
                if (uploadImage != null)
                {
                    byte[] imageData = null;
                    // считываем переданный файл в массив байтов
                    using (var binaryReader = new BinaryReader(uploadImage.InputStream))
                    {
                        imageData = binaryReader.ReadBytes(uploadImage.ContentLength);
                    }
                    // установка массива байтов
                    DBUserBusinessCard.Logo = imageData;
                }
                db.Entry(DBUserBusinessCard).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("GetBusinessCard"));
            }
            return(View());
        }
        public ActionResult CloneCard(int CardId, string ComingFrom, bool PickORCloneImg)
        {
            var model = new BusinessCard();


            if (ComingFrom == "defaultCards")
            {
                model                = _saveData.GetActiveCarddetaillsById(CardId);
                model.CardId         = 0;
                model.Ispublished    = false;
                model.IsDefault      = true;
                model.PickORCloneImg = PickORCloneImg;
                foreach (var ele in model.Elements)
                {
                    ele.Id = 0;
                }
            }
            else
            {
                model                = _saveData.GetActiveCarddetaillsById(CardId);
                model.CardId         = 0;
                model.Ispublished    = false;
                model.PickORCloneImg = PickORCloneImg;
                foreach (var ele in model.Elements)
                {
                    ele.Id = 0;
                }
            }

            ViewBag.AllElements   = _saveData.GetCardElementGroups();
            ViewBag.AllIcons      = _saveData.GetIconNames();
            ViewBag.AllCategories = _saveData.GetAllCategories();

            return(View("EditCard", model));
        }
Beispiel #4
0
        /// <summary>
        /// Deletes a card in the database
        /// </summary>
        /// <param name="id">The id of the item to be deleted</param>
        public async Task DeleteAsync(int id)
        {
            BusinessCard card = await GetCardByIdAsync(id);

            _context.Cards.Remove(card);
            await _context.SaveChangesAsync();
        }
Beispiel #5
0
        public async Task <ActionResult> GetBusinessCard(UIBusinessCard UserBusinessCard, HttpPostedFileBase uploadImage)
        {
            ApplicationUser user = await GetCurrentUser();

            if (ModelState.IsValid)
            {
                //конфигурация маппера
                Mapper.Initialize(cfg => cfg.CreateMap <UIBusinessCard, BusinessCard>());
                //сопоставление
                BusinessCard DBUserBusinessCard = Mapper.Map <UIBusinessCard, BusinessCard>(UserBusinessCard);
                DBUserBusinessCard.User = user;
                byte[] imageData = null;
                // считываем переданный файл в массив байтов
                using (var binaryReader = new BinaryReader(uploadImage.InputStream))
                {
                    imageData = binaryReader.ReadBytes(uploadImage.ContentLength);
                }
                // установка массива байтов
                DBUserBusinessCard.Logo = imageData;
                user.BusinessCard       = DBUserBusinessCard;
                db.Users.Attach(user);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index", "Vacancies"));
            }
            return(View());
        }
Beispiel #6
0
 public static void Main()
 {
     #region 변수와 배열
     //[1] 변수(Variable) : 하나의 이름으로 하나의 데이터형식을 하나만 보관
     string name = "홍길동";
     int    age  = 21;
     Print(name, age);
     //[2] 배열(Array) : 하나의 이름으로 하나의 데이터 형식을 하나 이상 보관
     object[] address = new object[2];
     address[0] = "백두산";
     address[1] = 100;
     Print(address[0], address[1]);
     #endregion
     //[3] 구조체 변수: 구조체 형식의 변수 선언
     BusinessCard biz;
     biz.Name = "임꺽정";
     biz.Age  = 40;
     Print(biz.Name, biz.Age);
     //[4] 구조체 배열
     BusinessCard[] names = new BusinessCard[2];
     names[0].Name = "한라산"; names[0].Age = 1;
     names[1].Name = "지리산"; names[1].Age = 11;
     for (int i = 0; i < names.Length; i++)
     {
         Print(names[i].Name, names[i].Age);
     }
 }
        public ActionResult CreateCard(int basecard = 0, bool PickORCloneImg = false)
        {
            var model = new BusinessCard();

            if (basecard == 0)
            {
                model.Cardname      = "New Business Card";
                model.Cardshape     = 1;
                model.Cardfrontfile = "";
                model.Cardbackfile  = "";
                model.Category      = 0;
            }
            else
            {
                model                = _saveData.GetActiveCarddetaillsById(basecard);
                model.CardId         = 0;
                model.PickORCloneImg = PickORCloneImg;
                model.Ispublished    = false;
                foreach (var ele in model.Elements)
                {
                    ele.Id = 0;
                }
            }

            ViewBag.AllElements   = _saveData.GetCardElementGroups();
            ViewBag.AllIcons      = _saveData.GetIconNames();
            ViewBag.AllCategories = _saveData.GetAllCategories();

            return(View("EditCard", model));
        }
Beispiel #8
0
        public Task <bool> SaveAsync(BusinessCard model, bool references = true, CancellationToken token = default)
        {
            var exceptions = new List <Exception>();
            var saved      = false;

            try
            {
                using (var scope = TransactionScopeOption.Required.CreateTransactionScopeFlow())
                {
                    saved = cards.Upsert(model.Id, model);
                    scope.Complete();
                }
            }
            catch (OperationCanceledException ex)
            {
                exceptions.Add(ex);
            }
            catch (Exception ex)
            {
                exceptions.Add(ex);
            }
            if (exceptions.Any())
            {
                throw new AggregateException(exceptions);
            }
            return(Task.FromResult(saved));
        }
        public async Task <ActionResult <BusinessCard> > PostBusinessCard(BusinessCard businessCard)
        {
            _context.BusinessCard.Add(businessCard);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetBusinessCard", new { id = businessCard.Id }, businessCard));
        }
Beispiel #10
0
 public void SaveNewBusinessCard(BusinessCard businessCard)
 {
     using (var context = new DataContext())
     {
         context.BusinessCards.InsertOnSubmit(card);
         context.SubmitChanges();
     }
 }
Beispiel #11
0
        public ActionResult DeleteConfirmed(int id)
        {
            BusinessCard businessCard = db.BusinessCards.Find(id);

            db.BusinessCards.Remove(businessCard);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #12
0
        static void Main(string[] args)
        {
            BusinessCard bc = new BusinessCard();

            bc.CountUAH = 100;

            bc.ShowBalance();
        }
        public IActionResult CardsFiltering([FromForm] BusinessCard Businesscard)
        {
            var FilteredData = new List <BusinessCard>();

            FilteredData          = _saveData.CardsFiltering(Businesscard.Category, Businesscard.Cardname, Businesscard.IscameFrom);
            ViewBag.AllCategories = _saveData.GetAllCategories();
            return(PartialView("_CardsList", FilteredData));
        }
Beispiel #14
0
        private void PrintBusinessCard()
        {
            var card = new BusinessCard();
            var user = this.component.GetUserById(PluginContext.Host.ConnectedUser.Id);

            card.DataContext = BusinessCardViewModel.CreateFrom(user);

            card.Print();
        }
Beispiel #15
0
        public async Task UnregisterAsync(BusinessCard model, bool?references = null, CancellationToken cancellation = default)
        {
            var exists = await ContainsKeyAsync(model.Id, cancellation).ConfigureAwait(false);

            if (!exists)
            {
                model.Id = generator.GetNullKey();
            }
        }
Beispiel #16
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            BusinessCard DBUserBusinessCard = await db.BusinessCards.FindAsync(id);

            db.BusinessCards.Remove(DBUserBusinessCard);
            await db.SaveChangesAsync();

            return(RedirectToAction("GetBusinessCard"));
        }
Beispiel #17
0
        public void Unregister(BusinessCard model, bool?references = null)
        {
            var exists = ContainsKey(model.Id);

            if (!exists)
            {
                model.Id = generator.GetNullKey();
            }
        }
Beispiel #18
0
 public ActionResult Edit([Bind(Include = "ID,Name,CompanyName,Position,Address,Number,Email")] BusinessCard businessCard)
 {
     if (ModelState.IsValid)
     {
         db.Entry(businessCard).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(businessCard));
 }
Beispiel #19
0
    public void ViewClickedSave()
    {
        //You can have all your business logic here which is easy to unit test.
        var businessCard = new BusinessCard()
        {
            Field1 = view.Field1
        };

        _myCard.SaveNewBusinessCard(businessCard);
    }
Beispiel #20
0
        public bool Save(BusinessCard model, bool references = true)
        {
            var upserted = false;

            using (var scope = TransactionScopeOption.Required.CreateTransactionScope())
            {
                upserted = cards.Upsert(model);
                scope.Complete();
            }
            return(upserted);
        }
Beispiel #21
0
        public ActionResult Create([Bind(Include = "ID,Name,CompanyName,Position,Address,Number,Email")] BusinessCard businessCard)
        {
            if (ModelState.IsValid)
            {
                db.BusinessCards.Add(businessCard);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(businessCard));
        }
Beispiel #22
0
        /// <summary>
        /// Updates a card in the database
        /// </summary>
        /// <param name="card">The card to update</param>
        public async Task UpdateAsync(BusinessCard card)
        {
            var oldCard = await GetCardByIdAsync(card.Id);

            oldCard.Name      = card.Name;
            oldCard.SurName   = card.SurName;
            oldCard.Image     = card.Image;
            oldCard.Email     = card.Email;
            oldCard.Telephone = card.Telephone;

            await _context.SaveChangesAsync();
        }
Beispiel #23
0
        static void Main(string[] args)
        {
            BusinessCard bc = new BusinessCard();
            CreditCard   cc = new CreditCard();

            Money.Money m = new Money.Money();

            Console.WriteLine("Credit card: ");
            Console.WriteLine(cc);

            Console.WriteLine();
        }
Beispiel #24
0
        public async Task <OkResult> AddCard([FromBody] BusinessCard card)
        {
            try
            {
                await _service.AddAsync(card);
            }
            catch (Exception)
            {
                throw;
            }

            return(Ok());
        }
        public void GenerateValueLine_ReturnsCorrectValueLine()
        {
            BusinessCard card = new BusinessCard
            {
                CardId      = 0,
                Title       = "TestTitle",
                PhoneNumber = "0123456789"
            };
            const string EXPECTED_RESULT = "(0, 'TestTitle', '0123456789')";

            string result = generator.GenerateValueLine(card);

            Assert.AreEqual(EXPECTED_RESULT, result);
        }
Beispiel #26
0
        static void Main(string[] args)
        {
            BusinessCard bc = new BusinessCard();
            Money        m  = new Money();

            bc.CountUAH = 100;

            bc.ShowBalance();
            m.ShowMoney();
            Console.WriteLine(" ");


            CreditCard cr = new CreditCard();
        }
Beispiel #27
0
        public async Task <ActionResult> DeleteBusinessCard(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BusinessCard DBUserBusinessCard = await db.BusinessCards.FindAsync(id);

            if (DBUserBusinessCard == null)
            {
                return(HttpNotFound());
            }
            return(View(DBUserBusinessCard));
        }
Beispiel #28
0
        // GET: BusinessCards/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BusinessCard businessCard = db.BusinessCards.Find(id);

            if (businessCard == null)
            {
                return(HttpNotFound());
            }
            return(View(businessCard));
        }
        public ActionResult CreateCardTemplate()
        {
            var model = new BusinessCard();

            model.Cardname      = "New Card Template";
            model.Cardshape     = 1;
            model.Cardfrontfile = "";
            model.Cardbackfile  = "";
            model.IsDefault     = true;
            model.Category      = 0;

            ViewBag.AllElements   = _saveData.GetCardElementGroups();
            ViewBag.AllIcons      = _saveData.GetIconNames();
            ViewBag.AllCategories = _saveData.GetAllCategories();

            return(View("EditCard", model));
        }
        private static string InsertCard(BusinessCard card, string userId)
        {
            try
            {
                Card newCard = card.Card;
                newCard.Id = Guid.NewGuid().ToString();

                var query = DataLayer.Client.Cypher
                            .Create("(card : Card {newCard})")
                            .WithParam("newCard", newCard)
                            .With("card")
                            .Match("(user: User)", "(takeOf: Station)", "(arrival: Station)")
                            .Where((User user) => user.Id == userId)
                            .AndWhere((Station takeOf) => takeOf.Id == card.TakeOfStation.Id)
                            .AndWhere((Station arrival) => arrival.Id == card.ArrivalStation.Id)
                            .Create("(card) - [: CARD_BOUGHT] -> (user)")
                            .Create("(card) - [: CARD_ARRIVES_AT]->(arrival)")
                            .Create("(card) - [: CARD_TAKES_OF] -> (takeOf)")
                            .Return <Card>("card")
                            .Results;

                if (query != null)
                {
                    foreach (var ride in card.Rides)
                    {
                        var q = DataLayer.Client.Cypher
                                .Match("(c: Card),(r: Ride)")
                                .Where((Card c) => c.Id == newCard.Id)
                                .AndWhere((Ride r) => r.Id == ride.Ride.Id)
                                .Create("(c) - [: OF_RIDE] -> (r)")
                                .Return <Card>("c")
                                .Results;
                        if (q == null)
                        {
                            return(null);
                        }
                    }
                }

                return(newCard.Id);
            }
            catch (Exception e)
            {
                return(null);
            }
        }